Zelda Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2023-08-12 03:18:08
Exec Total Coverage
Lines: 8336 12130 68.7%
Functions: 93 126 73.8%
Branches: 5467 10293 53.1%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // ZQuest Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // qst.cc
6 //
7 // Code for loading '.qst' files in ZC and ZQuest.
8 //
9 //--------------------------------------------------------
10
11 #include "allegro/file.h"
12 #include "base/util.h"
13 #include "base/zapp.h"
14 #include "base/qrs.h"
15 #include "base/cpool.h"
16 #include "base/packfile.h"
17 #include "base/dmap.h"
18 #include "base/combo.h"
19 #include "base/msgstr.h"
20 #include <filesystem>
21 #include <stdio.h>
22 #include <string.h>
23 #include <string>
24 #include <map>
25 #include <vector>
26 #include <assert.h>
27 #include <fmt/format.h>
28
29
30 #include "metadata/sigs/devsig.h.sig"
31 #include "metadata/sigs/compilersig.h.sig"
32 #include "metadata/versionsig.h"
33 #include "base/zc_alleg.h"
34 #include "base/zdefs.h"
35 #include "base/colors.h"
36 #include "tiles.h"
37 #include "base/zsys.h"
38 #include "qst.h"
39 #include "defdata.h"
40 #include "subscr.h"
41 #include "font.h"
42 #include "zc/replay.h"
43 #include "zc/zc_custom.h"
44 #include "sfx.h"
45 #include "md5.h"
46 #include "zinfo.h"
47 #include "zc/ffscript.h"
48 #include "particles.h"
49 #include "dialog/alert.h"
50 #include "base/misctypes.h"
51
52 #ifdef __EMSCRIPTEN__
53 #include "base/emscripten_utils.h"
54 #endif
55
56 //FFScript FFCore;
57 extern FFScript FFCore;
58 extern ZModule zcm;
59 extern zcmodule moduledata;
60 extern uint8_t __isZQuest;
61 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
62 extern particle_list particles;
63 extern void setZScriptVersion(int32_t s_version);
64 //FFSCript FFEngine;
65
66 int32_t temp_ffscript_version = 0;
67 static bool read_ext_zinfo = false, read_zinfo = false;
68 static bool loadquest_report = false;
69 static char const* loading_qst_name = NULL;
70 static byte loading_qst_num = 0;
71
72 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0};
73 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
74
75 #ifdef _MSC_VER
76 #define strncasecmp _strnicmp
77 #endif
78
79 #ifndef _AL_MALLOC
80 #define _AL_MALLOC(a) _al_malloc(a)
81 #define _AL_FREE(a) _al_free(a)
82 #endif
83
84 using std::string;
85 using std::pair;
86
87 // extern bool debug;
88 extern int32_t hero_animation_speed; //lower is faster animation
89 extern std::vector<mapscr> TheMaps;
90 extern std::vector<word> map_autolayers;
91 extern zcmap *ZCMaps;
92 extern byte *colordata;
93 //extern byte *tilebuf;
94 extern tiledata *newtilebuf;
95 extern byte *trashbuf;
96 extern itemdata *itemsbuf;
97 extern wpndata *wpnsbuf;
98 extern comboclass *combo_class_buf;
99 extern guydata *guysbuf;
100 extern ZCHEATS zcheats;
101 extern zinitdata zinit;
102 extern char palnames[MAXLEVELS][17];
103 extern int32_t memrequested;
104 extern char *byte_conversion(int32_t number, int32_t format);
105 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
106 string zScript;
107 46 std::map<int32_t, script_slot_data > ffcmap;
108 46 std::map<int32_t, script_slot_data > globalmap;
109 46 std::map<int32_t, script_slot_data > genericmap;
110 46 std::map<int32_t, script_slot_data > itemmap;
111 46 std::map<int32_t, script_slot_data > npcmap;
112 46 std::map<int32_t, script_slot_data > ewpnmap;
113 46 std::map<int32_t, script_slot_data > lwpnmap;
114 46 std::map<int32_t, script_slot_data > playermap;
115 46 std::map<int32_t, script_slot_data > dmapmap;
116 46 std::map<int32_t, script_slot_data > screenmap;
117 46 std::map<int32_t, script_slot_data > itemspritemap;
118 46 std::map<int32_t, script_slot_data > comboscriptmap;
119 void free_newtilebuf();
120 bool combosread=false;
121 bool mapsread=false;
122 bool fixffcs=false;
123 bool fixpolsvoice=false;
124
125 const std::string script_slot_data::DEFAULT_FORMAT = "%s %s";
126 const std::string script_slot_data::INVALID_FORMAT = "%s --%s";
127 const std::string script_slot_data::DISASSEMBLED_FORMAT = "%s ++%s";
128 const std::string script_slot_data::ZASM_FORMAT = "%s ==%s";
129
130 char qstdat_string[2048] = { 0 };
131
132 static zinfo* load_tmp_zi = NULL;
133
134 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
135 const byte clavio[9]={97,109,111,110,103,117,115,0};
136
137 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
138 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
139
140 const char *qst_error[] =
141 {
142 "OK","File not found","Invalid quest file",
143 "Version not supported","Obsolete version",
144 "Missing new data" , /* but let it pass in ZQuest */
145 "Internal error occurred", "Invalid password",
146 "Doesn't match saved game", "Save file is for older version of quest; please start new save",
147 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
148 };
149
150 //for legacy quests -DD
151 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
152 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
153 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
154 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
155 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
156 };
157
158 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
159
160
161 void delete_combo_aliases()
162 {
163 for(int32_t j(0); j<256; j++)
164 {
165 if(combo_aliases[j].combos != NULL)
166 {
167 delete[] combo_aliases[j].combos;
168 combo_aliases[j].combos=NULL;
169 }
170
171 if(combo_aliases[j].csets != NULL)
172 {
173 delete[] combo_aliases[j].csets;
174 combo_aliases[j].csets=NULL;
175 }
176 }
177
178 }
179
180 char *byte_conversion(int32_t number, int32_t format)
181 {
182 static char num_str[40];
183
184 if(format==-1) //auto
185 {
186 format=1; //bytes
187
188 if(number>1024)
189 {
190 format=2; //kilobytes
191 }
192
193 if(number>1024*1024)
194 {
195 format=3; //megabytes
196 }
197
198 if(number>1024*1024*1024)
199 {
200 format=4; //gigabytes (dude, what are you doing?)
201 }
202 }
203
204 switch(format)
205 {
206 case 1: //bytes
207 sprintf(num_str,"%db",number);
208 break;
209
210 case 2: //kilobytes
211 sprintf(num_str,"%.2fk",float(number)/1024);
212 break;
213
214 case 3: //megabytes
215 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
216 break;
217
218 case 4: //gigabytes
219 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
220 break;
221
222 default:
223 abort();
224 break;
225 }
226
227 return num_str;
228 }
229
230 644 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
231 {
232 static char num_str1[40];
233 static char num_str2[40];
234 static char num_str[80];
235
236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(format1==-1) //auto
237 {
238 644 format1=1; //bytes
239
240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(number1>1024)
241 {
242 644 format1=2; //kilobytes
243 644 }
244
245
2/2
✓ Branch 0 taken 460 times.
✓ Branch 1 taken 184 times.
644 if(number1>1024*1024)
246 {
247 184 format1=3; //megabytes
248 184 }
249
250
1/2
✓ Branch 0 taken 644 times.
✗ Branch 1 not taken.
644 if(number1>1024*1024*1024)
251 {
252 format1=4; //gigabytes (dude, what are you doing?)
253 }
254 644 }
255
256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(format2==-1) //auto
257 {
258 644 format2=1; //bytes
259
260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 644 times.
644 if(number2>1024)
261 {
262 644 format2=2; //kilobytes
263 644 }
264
265
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 598 times.
644 if(number2>1024*1024)
266 {
267 598 format2=3; //megabytes
268 598 }
269
270
1/2
✓ Branch 0 taken 644 times.
✗ Branch 1 not taken.
644 if(number2>1024*1024*1024)
271 {
272 format2=4; //gigabytes (dude, what are you doing?)
273 }
274 644 }
275
276
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 460 times.
✓ Branch 3 taken 184 times.
✗ Branch 4 not taken.
644 switch(format1)
277 {
278 case 1: //bytes
279 sprintf(num_str1,"%db",number1);
280 break;
281
282 case 2: //kilobytes
283 460 sprintf(num_str1,"%.2fk",float(number1)/1024);
284 460 break;
285
286 case 3: //megabytes
287 184 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
288 184 break;
289
290 case 4: //gigabytes
291 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
292 break;
293
294 default:
295 abort();
296 break;
297 }
298
299
2/5
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 598 times.
✗ Branch 4 not taken.
644 switch(format2)
300 {
301 case 1: //bytes
302 sprintf(num_str2,"%db",number2);
303 break;
304
305 case 2: //kilobytes
306 46 sprintf(num_str2,"%.2fk",float(number2)/1024);
307 46 break;
308
309 case 3: //megabytes
310 598 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
311 598 break;
312
313 case 4: //gigabytes
314 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
315 break;
316
317 default:
318 abort();
319 break;
320 }
321
322 644 sprintf(num_str, "%s/%s", num_str1, num_str2);
323 644 return num_str;
324 }
325
326 char *ordinal(int32_t num)
327 {
328 static const char *ending[4] = {"st","nd","rd","th"};
329 static char ord_str[8];
330
331 char *end;
332 int32_t t=(num%100)/10;
333 int32_t n=num%10;
334
335 if(n>=1 && n<4 && t!=1)
336 end = (char *)ending[n-1];
337 else
338 end = (char *)ending[3];
339
340 sprintf(ord_str,"%d%s",num%10000,end);
341 return ord_str;
342 }
343
344 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
345 {
346 int32_t ret;
347 *version=0;
348 *build=0;
349 byte temp_map_count=map_count;
350 byte temp_midi_flags[MIDIFLAGS_SIZE];
351 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
352
353 zquestheader tempheader;
354
355 if(!f)
356 {
357 return qe_invalid;
358 }
359
360 ret=readheader(f, &tempheader);
361
362 if(ret)
363 {
364 return ret;
365 }
366
367 map_count=temp_map_count;
368 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
369 *version=tempheader.zelda_version;
370 *build=tempheader.build;
371 return 0;
372 }
373
374
375 bool find_section(PACKFILE *f, int32_t section_id_requested)
376 {
377
378 if(!f)
379 {
380 return false;
381 }
382
383 int32_t section_id_read;
384 bool catchup=false;
385 word dummy;
386 byte tempbyte;
387 char tempbuf[65536];
388
389
390 switch(section_id_requested)
391 {
392 case ID_RULES:
393 case ID_STRINGS:
394 case ID_MISC:
395 case ID_TILES:
396 case ID_COMBOS:
397 case ID_CSETS:
398 case ID_MAPS:
399 case ID_DMAPS:
400 case ID_DOORS:
401 case ID_ITEMS:
402 case ID_WEAPONS:
403 case ID_COLORS:
404 case ID_ICONS:
405 case ID_INITDATA:
406 case ID_GUYS:
407 case ID_MIDIS:
408 case ID_CHEATS:
409 break;
410
411 default:
412 al_trace("Bad section requested!\n");
413 return false;
414 break;
415 }
416
417 dword section_size;
418
419 //section id
420 if(!p_mgetl(&section_id_read,f))
421 {
422 return false;
423 }
424
425 while(!pack_feof(f))
426 {
427 switch(section_id_read)
428 {
429 case ID_RULES:
430 case ID_STRINGS:
431 case ID_MISC:
432 case ID_TILES:
433 case ID_COMBOS:
434 case ID_CSETS:
435 case ID_MAPS:
436 case ID_DMAPS:
437 case ID_DOORS:
438 case ID_ITEMS:
439 case ID_WEAPONS:
440 case ID_COLORS:
441 case ID_ICONS:
442 case ID_INITDATA:
443 case ID_GUYS:
444 case ID_MIDIS:
445 case ID_CHEATS:
446 catchup=false;
447 break;
448
449 default:
450 break;
451 }
452
453
454 while(catchup)
455 {
456 //section id
457 section_id_read=(section_id_read<<8);
458
459 if(!p_getc(&tempbyte,f))
460 {
461 return false;
462 }
463
464 section_id_read+=tempbyte;
465 }
466
467 if(section_id_read==section_id_requested)
468 {
469 return true;
470 }
471 else
472 {
473 //section version info
474 if(!p_igetw(&dummy,f))
475 {
476 return false;
477 }
478
479 if(!p_igetw(&dummy,f))
480 {
481 return false;
482 }
483
484 //section size
485 if(!p_igetl(&section_size,f))
486 {
487 return false;
488 }
489
490 //pack_fseek(f, section_size);
491 while(section_size>65535)
492 {
493 pfread(tempbuf,65535,f);
494 tempbuf[65535]=0;
495 section_size-=65535;
496 }
497
498 if(section_size>0)
499 {
500 pfread(tempbuf,section_size,f);
501 tempbuf[section_size]=0;
502 }
503 }
504
505 //section id
506 if(!p_mgetl(&section_id_read,f))
507 {
508 return false;
509 }
510 }
511
512 return false;
513 }
514
515
516
517
518
519 bool valid_zqt(PACKFILE *f)
520 {
521
522 //word tiles_used;
523 //word combos_used;
524 //open the file
525 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
526 if(!f)
527 return false;
528
529 //for now, everything else is valid
530 return true;
531
532 /*int16_t version;
533 byte build;
534
535 //read the version and make sure it worked
536 if(!p_igetw(&version,f))
537 {
538 goto error;
539 }
540
541 //read the build and make sure it worked
542 if(!p_getc(&build,f))
543 goto error;
544
545 //read the tile info and make sure it worked
546 if(!p_igetw(&tiles_used,f))
547 {
548 goto error;
549 }
550
551 for (int32_t i=0; i<tiles_used; i++)
552 {
553 if(!pfread(trashbuf,tilesize(tf4Bit),f))
554 {
555 goto error;
556 }
557 }
558
559 //read the combo info and make sure it worked
560 if(!p_igetw(&combos_used,f))
561 {
562 goto error;
563 }
564 for (int32_t i=0; i<combos_used; i++)
565 {
566 if(!pfread(trashbuf,sizeof(newcombo),f))
567 {
568 goto error;
569 }
570 }
571
572 //read the palette info and make sure it worked
573 for (int32_t i=0; i<48; i++)
574 {
575 if(!pfread(trashbuf,newpdTOTAL,f))
576 {
577 goto error;
578 }
579 }
580 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
581 {
582 goto error;
583 }
584 for (int32_t i=0; i<MAXLEVELS; i++)
585 {
586 if(!pfread(trashbuf,PALNAMESIZE,f))
587 {
588 goto error;
589 }
590 }
591
592 //read the sprite info and make sure it worked
593 for (int32_t i=0; i<MAXITEMS; i++)
594 {
595 if(!pfread(trashbuf,sizeof(itemdata),f))
596 {
597 goto error;
598 }
599 }
600
601 for (int32_t i=0; i<MAXWPNS; i++)
602 {
603 if(!pfread(trashbuf,sizeof(wpndata),f))
604 {
605 goto error;
606 }
607 }
608
609 //read the triforce pieces info and make sure it worked
610 for (int32_t i=0; i<8; ++i)
611 {
612 if(!p_getc(&trashbuf,f))
613 {
614 goto error;
615 }
616 }
617
618
619
620 //read the game icons info and make sure it worked
621 for (int32_t i=0; i<4; ++i)
622 {
623 if(!p_igetw(&trashbuf,f))
624 {
625 goto error;
626 }
627 }
628
629 //read the misc colors info and map styles info and make sure it worked
630 if(!pfread(trashbuf,sizeof(zcolors),f))
631 {
632 goto error;
633 }
634
635 //read the template screens and make sure it worked
636 byte num_maps;
637 if(!p_getc(&num_maps,f))
638 {
639 goto error;
640 }
641 for (int32_t i=0; i<TEMPLATES; i++)
642 {
643 if(!pfread(trashbuf,sizeof(mapscr),f))
644 {
645 goto error;
646 }
647 }
648 if (num_maps>1) //dungeon templates
649 {
650 for (int32_t i=0; i<TEMPLATES; i++)
651 {
652 if(!pfread(trashbuf,sizeof(mapscr),f))
653 {
654 goto error;
655 }
656 }
657 }
658
659 //yay! it worked! close the file and say everything was ok.
660 pack_fclose(f);
661 return true;
662
663 error:
664 pack_fclose(f);
665 return false;*/
666 }
667
668 bool valid_zqt(const char *filename)
669 {
670 PACKFILE *f=NULL;
671 bool isvalid;
672 int32_t error;
673 f=open_quest_file(&error, filename, false);
674
675 if(!f)
676 {
677 // setPackfilePassword(NULL);
678 return false;
679 }
680
681 isvalid=valid_zqt(f);
682
683 clear_quest_tmpfile();
684 pack_fclose(f);
685
686 // setPackfilePassword(NULL);
687 return isvalid;
688 }
689
690 static std::string tmp_file_name;
691 258 void clear_quest_tmpfile()
692 {
693
1/2
✓ Branch 0 taken 258 times.
✗ Branch 1 not taken.
258 if(tmp_file_name.size())
694 {
695 if(exists(tmp_file_name.c_str()))
696 delete_file(tmp_file_name.c_str());
697 tmp_file_name.clear();
698 }
699 258 }
700 /*
701 .qst file history
702
703 .qst files have always been compressed using allegro's packfiles.
704
705 At some point, an encoding layer was added. The two layers look like this:
706
707 1) The top layer is from us. See decode_file_007.
708 [0-24] Preamble "Zelda Classic Quest File"
709 [25-28] Initial decoding seed value.
710 [29-X] Allegro-encoded payload (AKA "packed" file)
711 [last 4] Checksum
712
713 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
714 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
715 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
716 The oldest quests skip the password part.
717
718 Simply, the job of this function is to peel away the top layer.
719
720 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
721 in opening and saving files. There is no version field, so they decryption key is
722 found via trial-by-error (very slow!)
723
724 There are other file types of interest:
725 - .zqt: quest template files, skips top-layer encryption pass
726 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
727 - .qu?: same as above. automated backup files
728 - .qb?: same as above. automated backup files
729 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
730
731 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
732 files are now "slh!.AG ZC Enhanced Quest File".
733 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
734 */
735 129 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
736 {
737
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (show_progress)
738 {
739 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
740 }
741
742 #ifdef __EMSCRIPTEN__
743 if (em_is_lazy_file(filename))
744 {
745 em_fetch_file(filename);
746 }
747 #endif
748 129 clear_quest_tmpfile();
749 // Note: although this is primarily for loading .qst files, it can also handle all of the
750 // file types mentioned in the comment above. No need to be told if the file being loaded
751 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
752 129 bool top_layer_compressed = false;
753 129 bool compressed = false;
754 129 bool encrypted = false;
755
756 // Input files may or may not include a top layer, which may or may not be compressed.
757 // Additionally, the bottom layer may or may not be compressed, and may or may not be encoded
758 // with an allegro packfile password (longtan).
759 // We peek into this file to read the header - we'll either see the top layer's header (ENC_STR)
760 // or the bottom layer's header (QH_IDSTR or QH_NEWIDSTR).
761 // Newly saved .qst files enjoy a fast path here, where there is no top layer at all.
762
763 129 bool id_came_from_compressed_file = false;
764 129 const char* packfile_password = "";
765 char id[32];
766 129 id[0] = id[31] = '\0';
767 129 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, "");
768
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (!pf)
769 3 pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password = datapwd);
770
2/2
✓ Branch 0 taken 126 times.
✓ Branch 1 taken 3 times.
129 if (pf)
771 {
772 126 id_came_from_compressed_file = true;
773
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (!pack_fread(id, sizeof(id)-1, pf))
774 {
775 pack_fclose(pf);
776 Z_message("Unable to read header string\n");
777 return nullptr;
778 }
779 126 pack_fclose(pf);
780 126 }
781 else
782 {
783 3 FILE* f = fopen(filename, "rb");
784
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if (!f)
785 {
786 *open_error=qe_notfound;
787 return nullptr;
788 }
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if (!fread(id, sizeof(char), sizeof(id)-1, f))
790 {
791 fclose(f);
792 Z_message("Unable to read header string\n");
793 return nullptr;
794 }
795 3 fclose(f);
796 }
797
798
4/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 122 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 3 times.
129 if (strstr(id, QH_NEWIDSTR) || strstr(id, QH_IDSTR))
799 {
800 // The given file is already just the bottom layer - nothing more to do.
801 // There's no way to rewind a packfile, so just open it again.
802
1/2
✓ Branch 0 taken 126 times.
✗ Branch 1 not taken.
126 if (id_came_from_compressed_file)
803 {
804 126 return pack_fopen_password(filename, F_READ_PACKED, packfile_password);
805 }
806 else
807 {
808 return pack_fopen_password(filename, F_READ, "");
809 }
810 }
811
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 else if (strstr(id, ENC_STR))
812 {
813 3 top_layer_compressed = id_came_from_compressed_file;
814 3 compressed = true;
815 3 encrypted = true;
816 3 }
817 else if (id_came_from_compressed_file && strstr(id, "slh!\xff"))
818 {
819 // We must be reading the compressed contents of an allegro dataobject file. ex: `classic_qst.dat#NESQST_NEW_QST`.
820 // Let's extract the content and re-open as a separate file, so allegro will uncompress correctly.
821
822 char tmpfilename[L_tmpnam];
823 std::tmpnam(tmpfilename);
824 FILE* tf = fopen(tmpfilename, "wb");
825 PACKFILE* pf = pack_fopen_password(filename, F_READ_PACKED, packfile_password);
826
827 int c;
828 while ((c = pack_getc(pf)) != EOF)
829 {
830 fputc(c, tf);
831 }
832 fclose(tf);
833 pack_fclose(pf);
834
835 tmp_file_name = tmpfilename; //store so it can be cleaned up later
836
837 // not good: temp file storage leak. Callers don't know to delete temp files anymore.
838 // We should put qsu in the dat file, or use a separate .qst file for new qst.
839 return pack_fopen_password(tmpfilename, F_READ_PACKED, "");
840 }
841 else
842 {
843 // Unexpected, this is going to fail some header check later.
844 }
845
846 // Everything below here is legacy code - recently saved quest files will have
847 // returned by now.
848
849 char tmpfilename[L_tmpnam];
850 3 temp_name(tmpfilename);
851 char percent_done[30];
852 3 int32_t current_method=0;
853
854 PACKFILE *f;
855 3 const char *passwd= encrypted ? datapwd : "";
856
857 // oldquest flag is set when an unencrypted qst file is suspected.
858 3 bool oldquest = false;
859 int32_t ret;
860
861
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(strcmp(filename, "default.qst")!=0)
862 {
863 3 box_out(filename);
864 3 }
865 else
866 {
867 box_out("new quest"); // Or whatever
868 }
869 3 box_out("...");
870 3 box_eol();
871 3 box_eol();
872
873
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(encrypted)
874 {
875 3 box_out("Decrypting...");
876 3 box_save_x();
877 3 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
878
879
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(ret)
880 {
881 switch(ret)
882 {
883 case 1:
884 box_out("error.");
885 box_eol();
886 box_end(true);
887 *open_error=qe_notfound;
888 return NULL;
889
890 case 2:
891 box_out("error.");
892 box_eol();
893 box_end(true);
894 *open_error=qe_internal;
895 return NULL;
896 // be sure not to delete tmpfilename now...
897 }
898
899 if(ret==5) //old encryption?
900 {
901 current_method++;
902 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
903 box_out(percent_done);
904 box_load_x();
905 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
906 }
907
908 if(ret==5) //old encryption?
909 {
910 current_method++;
911 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
912 box_out(percent_done);
913 box_load_x();
914 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
915 }
916
917 if(ret==5) //old encryption?
918 {
919 current_method++;
920 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
921 box_out(percent_done);
922 box_load_x();
923 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
924 }
925
926 if(ret==5) //old encryption?
927 {
928 current_method++;
929 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
930 box_out(percent_done);
931 box_load_x();
932 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
933 }
934
935 if(ret)
936 {
937 oldquest = true;
938 passwd="";
939 }
940 }
941
942 3 box_out("okay.");
943 3 box_eol();
944 3 }
945 else
946 {
947 oldquest = true;
948 }
949
950 3 box_out("Opening...");
951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
952
1/2
✓ Branch 0 taken 3 times.
✗ Branch 1 not taken.
3 if(!f)
953 {
954 if((compressed==1)&&(errno==EDOM))
955 {
956 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
957 }
958
959 if(!f)
960 {
961 if(!oldquest)
962 {
963 delete_file(tmpfilename);
964 }
965 box_out("error.");
966 box_eol();
967 box_end(true);
968 *open_error=qe_invalid;
969 return NULL;
970 }
971 }
972
973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(!oldquest)
974 {
975 3 delete_file(tmpfilename);
976 3 }
977
978 3 box_out("okay.");
979 3 box_eol();
980
981 3 return f;
982 129 }
983
984 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
985 {
986 char *filename;
987 PACKFILE *f=NULL;
988 int32_t open_error=0;
989
990 strcpy(qstdat_string, "modules/classic/default.qst");
991 if(Header->templatepath[0]==0)
992 {
993 filename=(char *)malloc(2048);
994 strcpy(filename, qstdat_string);
995 }
996 else
997 {
998 // TODO: should be safe to remove this, no one seems to use custom quest templates.
999 filename=Header->templatepath;
1000 }
1001
1002 f=open_quest_file(&open_error, filename, false);
1003
1004 if(Header->templatepath[0]==0)
1005 {
1006 free(filename);
1007 }
1008
1009 if(!f)
1010 {
1011 return NULL;
1012 }
1013
1014 if(validate)
1015 {
1016 if(!valid_zqt(f))
1017 {
1018 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
1019 pack_fclose(f);
1020 clear_quest_tmpfile();
1021 return NULL;
1022 }
1023 }
1024
1025 return f;
1026 }
1027
1028 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
1029 {
1030 // We absolutely do not support loading from a template file to initialize data outside the editor.
1031 // TODO: move this code into zq/
1032 if (get_app_id() != App::zquest) return false;
1033
1034 combosread=false;
1035 mapsread=false;
1036 fixffcs=false;
1037
1038 switch(section_id)
1039 {
1040 case ID_RULES:
1041 case ID_STRINGS:
1042 case ID_MISC:
1043 case ID_TILES:
1044 case ID_COMBOS:
1045 case ID_CSETS:
1046 case ID_MAPS:
1047 case ID_DMAPS:
1048 case ID_DOORS:
1049 case ID_ITEMS:
1050 case ID_WEAPONS:
1051 case ID_COLORS:
1052 case ID_ICONS:
1053 case ID_INITDATA:
1054 case ID_GUYS:
1055 case ID_MIDIS:
1056 case ID_CHEATS:
1057 case ID_ITEMDROPSETS:
1058 case ID_FAVORITES:
1059 break;
1060
1061 default:
1062 return false;
1063 break;
1064 }
1065
1066 int32_t ret;
1067 word version, build;
1068 PACKFILE *f=NULL;
1069
1070 char deletefilename[1024];
1071 deletefilename[0]=0;
1072
1073 //why is this here?
1074 /*
1075 if(colordata==NULL)
1076 return false;
1077 */
1078
1079 //setPackfilePassword(datapwd);
1080 f=open_quest_template(Header, deletefilename, validate);
1081
1082 if(!f) //no file, nothing to delete
1083 {
1084 // setPackfilePassword(NULL);
1085 return false;
1086 }
1087
1088 ret=get_version_and_build(f, &version, &build);
1089
1090 if(ret||(version==0))
1091 {
1092 pack_fclose(f);
1093 clear_quest_tmpfile();
1094
1095 if(deletefilename[0])
1096 {
1097 delete_file(deletefilename);
1098 }
1099
1100 // setPackfilePassword(NULL);
1101 return false;
1102 }
1103
1104 if(!find_section(f, section_id))
1105 {
1106 al_trace("Can't find section!\n");
1107 pack_fclose(f);
1108 clear_quest_tmpfile();
1109
1110 if(deletefilename[0])
1111 {
1112 delete_file(deletefilename);
1113 }
1114
1115 //setPackfilePassword(NULL);
1116 return false;
1117 }
1118
1119 switch(section_id)
1120 {
1121 case ID_RULES:
1122 //rules
1123 ret=readrules(f, Header);
1124 break;
1125
1126 case ID_STRINGS:
1127 //strings
1128 ret=readstrings(f, Header);
1129 break;
1130
1131 case ID_MISC:
1132 //misc data
1133 ret=readmisc(f, Header, Misc);
1134 break;
1135
1136 case ID_TILES:
1137 //tiles
1138 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1139 break;
1140
1141 case ID_COMBOS:
1142 //combos
1143 clear_combos();
1144 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1145 combosread=true;
1146 break;
1147
1148 case ID_COMBOALIASES:
1149 //combos
1150 ret=readcomboaliases(f, Header, version, build);
1151 break;
1152
1153 case ID_CSETS:
1154 //color data
1155 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1156 break;
1157
1158 case ID_MAPS:
1159 //maps
1160 ret=readmaps(f, Header);
1161 mapsread=true;
1162 break;
1163
1164 case ID_DMAPS:
1165 //dmaps
1166 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1167 break;
1168
1169 case ID_DOORS:
1170 //door combo sets
1171 ret=readdoorcombosets(f, Header);
1172 break;
1173
1174 case ID_ITEMS:
1175 //items
1176 ret=readitems(f, version, build);
1177 break;
1178
1179 case ID_WEAPONS:
1180 //weapons
1181 ret=readweapons(f, Header);
1182 break;
1183
1184 case ID_COLORS:
1185 //misc. colors
1186 ret=readmisccolors(f, Header, Misc);
1187 break;
1188
1189 case ID_ICONS:
1190 //game icons
1191 ret=readgameicons(f, Header, Misc);
1192 break;
1193
1194 case ID_INITDATA:
1195 //initialization data
1196 ret=readinitdata(f, Header);
1197 break;
1198
1199 case ID_GUYS:
1200 //guys
1201 ret=readguys(f, Header);
1202 break;
1203
1204 case ID_MIDIS:
1205 //midis
1206 ret=readtunes(f, Header, tunes);
1207 break;
1208
1209 case ID_CHEATS:
1210 //cheat codes
1211 ret=readcheatcodes(f, Header);
1212 break;
1213
1214 case ID_ITEMDROPSETS:
1215 //item drop sets
1216 // Why is this one commented out?
1217 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1218 break;
1219
1220 case ID_FAVORITES:
1221 // favorite combos and aliases
1222 ret=readfavorites(f, version, build);
1223 break;
1224
1225 default:
1226 ret=-1;
1227 break;
1228 }
1229
1230 pack_fclose(f);
1231 clear_quest_tmpfile();
1232
1233 if(deletefilename[0])
1234 {
1235 delete_file(deletefilename);
1236 }
1237
1238 //setPackfilePassword(NULL);
1239 if(!ret)
1240 {
1241 return true;
1242 }
1243
1244 return false;
1245 }
1246
1247 bool init_tiles(bool validate, zquestheader *Header)
1248 {
1249 return init_section(Header, ID_TILES, NULL, NULL, validate);
1250 }
1251
1252 bool init_combos(bool validate, zquestheader *Header)
1253 {
1254 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1255 }
1256
1257 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1258 {
1259 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1260 }
1261
1262 129 void init_spritelists()
1263 {
1264
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(FFCore.quest_format[vZelda] < 0x255)
1265 {
1266 93 guys.setMax(255);
1267 93 items.setMax(255);
1268 93 Ewpns.setMax(255);
1269 93 Lwpns.setMax(255);
1270 93 Sitems.setMax(255);
1271 93 chainlinks.setMax(255);
1272 93 decorations.setMax(255);
1273 93 particles.setMax(255);
1274 93 }
1275 else
1276 {
1277 36 guys.setMax(255);
1278 36 items.setMax(255);
1279 36 Ewpns.setMax(255);
1280 36 Lwpns.setMax(255);
1281 36 Sitems.setMax(255);
1282 36 chainlinks.setMax(255);
1283 36 decorations.setMax(255);
1284 36 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1285 }
1286 129 }
1287
1288 46 bool reset_items(bool validate, zquestheader *Header)
1289 {
1290 46 bool ret = true;
1291
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if (get_app_id() == App::zquest)
1292 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1293
1294
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 11776 times.
11822 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1295
1296 46 return ret;
1297 }
1298
1299 bool reset_guys()
1300 {
1301 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1302 init_guys(V_GUYS);
1303 return true;
1304 }
1305
1306 bool reset_wpns(bool validate, zquestheader *Header)
1307 {
1308 bool ret = true;
1309 if (get_app_id() == App::zquest)
1310 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1311
1312 for(int32_t i=0; i<MAXWPNS; i++)
1313 reset_weaponname(i);
1314
1315 return ret;
1316 }
1317
1318 bool reset_mapstyles(bool validate, miscQdata *Misc)
1319 {
1320 Misc->colors.blueframe_tile = 20044;
1321 Misc->colors.blueframe_cset = 0;
1322 Misc->colors.triforce_tile = 23461;
1323 Misc->colors.triforce_cset = 1;
1324 Misc->colors.triframe_tile = 18752;
1325 Misc->colors.triframe_cset = 1;
1326 Misc->colors.overworld_map_tile = 16990;
1327 Misc->colors.overworld_map_cset = 2;
1328 Misc->colors.HCpieces_tile = 21160;
1329 Misc->colors.HCpieces_cset = 8;
1330 Misc->colors.dungeon_map_tile = 19651;
1331 Misc->colors.dungeon_map_cset = 8;
1332 return true;
1333 }
1334
1335 46 int32_t get_qst_buffers()
1336 {
1337 46 memrequested+=(sizeof(mapscr)*MAPSCRS);
1338 46 Z_message("Allocating map buffer (%s)... ", byte_conversion2(sizeof(mapscr)*MAPSCRS,memrequested,-1, -1));
1339 46 TheMaps.resize(MAPSCRS);
1340 46 map_autolayers.resize(6);
1341
1342
2/2
✓ Branch 0 taken 6256 times.
✓ Branch 1 taken 46 times.
6302 for(int32_t i(0); i<MAPSCRS; i++)
1343 6256 TheMaps[i].zero_memory();
1344
1345 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1346 46 Z_message("OK\n"); // Allocating map buffer...
1347
1348 46 memrequested+=(sizeof(zcmap)*MAXMAPS2);
1349 46 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(zcmap)*MAXMAPS2,memrequested,-1,-1));
1350
1351
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((ZCMaps=(zcmap*)malloc(sizeof(zcmap)*MAXMAPS2))==NULL)
1352 return 0;
1353
1354 46 Z_message("OK\n");
1355
1356 // Allocating space for all 65535 strings uses up 10.62MB...
1357 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1358 // (Shoelace's "Hero of Dreams" uses 1415.)
1359 // So let's be a bit generous and allow 4096 initially.
1360 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1361 // I tested it and it worked without flaw on 6/6/11. - L.
1362 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1363 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1364 // See https://discord.com/channels/876899628556091432/992984989073416242
1365 46 msg_strings_size = 8192;
1366 46 memrequested+=(sizeof(MsgStr)*msg_strings_size);
1367 46 Z_message("Allocating string buffer (%s)... ", byte_conversion2(sizeof(MsgStr)*msg_strings_size,memrequested,-1,-1));
1368
1369
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 MsgStrings = new MsgStr[msg_strings_size];
1370
1371 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1372
2/2
✓ Branch 0 taken 376832 times.
✓ Branch 1 taken 46 times.
376878 for(auto q = 0; q < msg_strings_size; ++q)
1373 {
1374 376832 MsgStrings[q].clear();
1375 376832 }
1376 46 Z_message("OK\n"); // Allocating string buffer...
1377
1378 46 memrequested+=(sizeof(DoorComboSet)*MAXDOORCOMBOSETS);
1379 46 Z_message("Allocating door combo buffer (%s)... ", byte_conversion2(sizeof(DoorComboSet)*MAXDOORCOMBOSETS,memrequested,-1,-1));
1380
1381
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1382 return 0;
1383
1384 46 Z_message("OK\n"); // Allocating door combo buffer...
1385
1386 46 memrequested+=(sizeof(dmap)*MAXDMAPS);
1387 46 Z_message("Allocating dmap buffer (%s)... ", byte_conversion2(sizeof(dmap)*MAXDMAPS,memrequested,-1,-1));
1388
1389
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((DMaps=(dmap*)malloc(sizeof(dmap)*MAXDMAPS))==NULL)
1390 return 0;
1391
1392 46 memset(DMaps, 0, sizeof(dmap)*MAXDMAPS);
1393 46 Z_message("OK\n"); // Allocating dmap buffer...
1394
1395 46 memrequested+=(sizeof(newcombo)*MAXCOMBOS);
1396 46 Z_message("Allocating combo buffer (%s)... ", byte_conversion2(sizeof(newcombo)*MAXCOMBOS,memrequested,-1,-1));
1397
1398 46 combobuf.clear();
1399 46 combobuf.resize(MAXCOMBOS);
1400 46 Z_message("OK\n"); // Allocating combo buffer...
1401
1402 46 memrequested+=(psTOTAL255);
1403 46 Z_message("Allocating color data buffer (%s)... ", byte_conversion2(psTOTAL255,memrequested,-1,-1));
1404
1405
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1406 return 0;
1407
1408 46 Z_message("OK\n"); // Allocating color data buffer...
1409
1410 46 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1411 46 Z_message("Allocating tile buffer (%s)... ", byte_conversion2(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)),memrequested,-1,-1));
1412
1413 46 free_newtilebuf();
1414
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1415 return 0;
1416
1417 46 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1418 //Z_message("Performed memset on tiles\n");
1419 46 clear_tiles(newtilebuf);
1420 //Z_message("Performed clear_tiles()\n");
1421 46 Z_message("OK\n"); // Allocating tile buffer...
1422
1423
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(is_zquest())
1424 {
1425 memrequested+=(NEWMAXTILES*(sizeof(tiledata)+tilesize(tf4Bit)));
1426 Z_message("Allocating tile grab buffer (%s)... ", byte_conversion2(NEWMAXTILES*sizeof(tiledata),memrequested,-1,-1));
1427
1428 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1429 return 0;
1430
1431 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1432 clear_tiles(grabtilebuf);
1433 Z_message("OK\n"); // Allocating tile grab buffer...
1434 }
1435
1436 46 memrequested+=(100000);
1437 46 Z_message("Allocating trash buffer (%s)... ", byte_conversion2(100000,memrequested,-1,-1));
1438
1439
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((trashbuf=(byte*)malloc(100000))==NULL)
1440 return 0;
1441
1442 46 Z_message("OK\n"); // Allocating trash buffer...
1443
1444 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1445 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1446 // fixed by ensuring there's actually itemdata there.
1447 // If you change this, be sure to update del_qst_buffers, too.
1448
1449 46 memrequested+=(sizeof(itemdata)*(MAXITEMS+1));
1450 46 Z_message("Allocating item buffer (%s)... ", byte_conversion2(sizeof(itemdata)*(MAXITEMS+1),memrequested,-1,-1));
1451
1452
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1453 return 0;
1454
1455 46 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1456 46 itemsbuf++;
1457 46 Z_message("OK\n"); // Allocating item buffer...
1458
1459 46 memrequested+=(sizeof(wpndata)*MAXWPNS);
1460 46 Z_message("Allocating weapon buffer (%s)... ", byte_conversion2(sizeof(wpndata)*MAXWPNS,memrequested,-1,-1));
1461
1462
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1463 return 0;
1464
1465 46 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1466 46 Z_message("OK\n"); // Allocating weapon buffer...
1467
1468 46 memrequested+=(sizeof(guydata)*MAXGUYS);
1469 46 Z_message("Allocating guy buffer (%s)... ", byte_conversion2(sizeof(guydata)*MAXGUYS,memrequested,-1,-1));
1470
1471
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1472 return 0;
1473
1474 46 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1475 46 Z_message("OK\n"); // Allocating guy buffer...
1476
1477 46 memrequested+=(sizeof(comboclass)*cMAX);
1478 46 Z_message("Allocating combo class buffer (%s)... ", byte_conversion2(sizeof(comboclass)*cMAX,memrequested,-1,-1));
1479
1480
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1481 return 0;
1482
1483 46 Z_message("OK\n"); // Allocating combo class buffer...
1484
1485 46 return 1;
1486 46 }
1487
1488
1489 46 void free_newtilebuf()
1490 {
1491
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 46 times.
46 if(newtilebuf)
1492 {
1493 for(int32_t i=0; i<NEWMAXTILES; i++)
1494 if(newtilebuf[i].data)
1495 free(newtilebuf[i].data);
1496
1497 free(newtilebuf);
1498 newtilebuf = 0;
1499 }
1500 46 }
1501
1502 void free_grabtilebuf()
1503 {
1504 if(is_zquest())
1505 {
1506 if(grabtilebuf)
1507 {
1508 for(int32_t i=0; i<NEWMAXTILES; i++)
1509 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1510
1511 free(grabtilebuf);
1512 grabtilebuf = 0;
1513 }
1514 }
1515 }
1516
1517 void del_qst_buffers()
1518 {
1519 al_trace("Cleaning maps. \n");
1520
1521 if(ZCMaps) free(ZCMaps);
1522
1523 if(MsgStrings) delete[] MsgStrings;
1524
1525 if(DoorComboSets) free(DoorComboSets);
1526
1527 if(DMaps) free(DMaps);
1528
1529 combobuf.clear();
1530
1531 if(colordata) free(colordata);
1532
1533 al_trace("Cleaning tile buffers. \n");
1534 free_newtilebuf();
1535 free_grabtilebuf();
1536
1537 al_trace("Cleaning misc. \n");
1538
1539 if(trashbuf) free(trashbuf);
1540
1541 // See get_qst_buffers
1542 if(itemsbuf)
1543 {
1544 itemsbuf--;
1545 free(itemsbuf);
1546 }
1547
1548 if(wpnsbuf) free(wpnsbuf);
1549
1550 if(guysbuf) free(guysbuf);
1551
1552 if(combo_class_buf) free(combo_class_buf);
1553 }
1554
1555 4 bool init_palnames()
1556 {
1557 // if(palnames==NULL)
1558 // return false;
1559
1560
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t x=0; x<MAXLEVELS; x++)
1561 {
1562
4/4
✓ Branch 0 taken 2036 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 4 times.
2048 switch(x)
1563 {
1564 case 0:
1565 4 sprintf(palnames[x],"Overworld");
1566 4 break;
1567
1568 case 10:
1569 4 sprintf(palnames[x],"Caves");
1570 4 break;
1571
1572 case 11:
1573 4 sprintf(palnames[x],"Passageways");
1574 4 break;
1575
1576 default:
1577 2036 sprintf(palnames[x],"%c",0);
1578 2036 break;
1579 }
1580 2048 }
1581
1582 4 return true;
1583 }
1584
1585 25210 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1586 {
1587 void *p;
1588
1589
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 p = _AL_MALLOC(MAX(size, alloc_size));
1590
1591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 25210 times.
25210 if(!p)
1592 {
1593 return NULL;
1594 }
1595
1596
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!pfread(p,size,f))
1597 {
1598 _AL_FREE(p);
1599 return NULL;
1600 }
1601
1602
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(pack_ferror(f))
1603 {
1604 _AL_FREE(p);
1605 return NULL;
1606 }
1607
1608 25210 return p;
1609 25210 }
1610
1611 /* read_midi:
1612 * Reads MIDI data from a datafile (this is not the same thing as the
1613 * standard midi file format).
1614 */
1615
1616 2302 static MIDI *read_midi(PACKFILE *f)
1617 {
1618 MIDI *m;
1619 int32_t c;
1620 2302 int16_t divisions=0;
1621 2302 int32_t len=0;
1622
1623 2302 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1624
1625
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!m)
1626 {
1627 return NULL;
1628 }
1629
1630
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1631 {
1632 73664 m->track[c].len = 0;
1633 73664 m->track[c].data = NULL;
1634 73664 }
1635
1636 2302 p_mgetw(&divisions,f);
1637 2302 m->divisions=divisions;
1638
1639
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1640 {
1641 73664 p_mgetl(&len,f);
1642 73664 m->track[c].len=len;
1643
1644
2/2
✓ Branch 0 taken 48454 times.
✓ Branch 1 taken 25210 times.
73664 if(m->track[c].len > 0)
1645 {
1646 25210 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1647
1648
1/2
✓ Branch 0 taken 25210 times.
✗ Branch 1 not taken.
25210 if(!m->track[c].data)
1649 {
1650 destroy_midi(m);
1651 return NULL;
1652 }
1653 25210 }
1654 73664 }
1655
1656 LOCK_DATA(m, sizeof(MIDI));
1657
1658
2/2
✓ Branch 0 taken 73664 times.
✓ Branch 1 taken 2302 times.
75966 for(c=0; c<MIDI_TRACKS; c++)
1659 {
1660
2/2
✓ Branch 0 taken 25210 times.
✓ Branch 1 taken 48454 times.
73664 if(m->track[c].data)
1661 {
1662 LOCK_DATA(m->track[c].data, m->track[c].len);
1663 25210 }
1664 73664 }
1665
1666 2302 return m;
1667 2302 }
1668
1669 void clear_combo(int32_t i)
1670 {
1671 combobuf[i].clear();
1672 }
1673
1674 void clear_combos()
1675 {
1676 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1677 clear_combo(tmpcounter);
1678 }
1679
1680 void pack_combos()
1681 {
1682 int32_t di = 0;
1683
1684 for(int32_t si=0; si<1024; si+=2)
1685 combobuf[di++] = combobuf[si];
1686
1687 for(; di<1024; di++)
1688 clear_combo(di);
1689 }
1690
1691 129 void reset_tunes(zctune *tune)
1692 {
1693
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1694 {
1695 32508 tune[i].reset();
1696 32508 }
1697 129 }
1698
1699
1700 /*void reset_midi(zcmidi_ *m)
1701 {
1702 m->title[0]=0;
1703 m->loop=1;
1704 m->volume=144;
1705 m->start=0;
1706 m->loop_start=-1;
1707 m->loop_end=-1;
1708 if(m->midi)
1709 {
1710 destroy_midi(m->midi);
1711 }
1712 m->midi=NULL;
1713 }
1714
1715
1716 void reset_midis(zcmidi_ *m)
1717 {
1718 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1719 {
1720 reset_midi(m+i);
1721 }
1722 }
1723 */
1724
1725 void reset_scr(int32_t scr)
1726 {
1727 /*
1728 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1729 for(unsigned i=0; i<sizeof(mapscr); i++)
1730 *(di++) = 0;
1731 TheMaps[scr].valid=mVERSION;
1732 */
1733
1734 TheMaps[scr].zero_memory();
1735 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1736
1737 for(int32_t i=0; i<6; i++)
1738 {
1739 //these will be uncommented later
1740 //TheMaps[scr].layerxsize[i]=16;
1741 //TheMaps[scr].layerysize[i]=11;
1742 TheMaps[scr].layeropacity[i]=255;
1743 }
1744
1745 TheMaps[scr].valid=mVERSION;
1746
1747 }
1748
1749 /* For reference:
1750
1751 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1752 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1753 */
1754
1755 3582 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1756 {
1757
2/2
✓ Branch 0 taken 16494 times.
✓ Branch 1 taken 1614 times.
18108 for(int32_t i=0; i<9; i++)
1758 {
1759
2/2
✓ Branch 0 taken 89124 times.
✓ Branch 1 taken 14526 times.
103650 for(int32_t j=0; j<6; j++)
1760 {
1761
2/2
✓ Branch 0 taken 29052 times.
✓ Branch 1 taken 60072 times.
89124 if(j<4)
1762 {
1763
2/2
✓ Branch 0 taken 58104 times.
✓ Branch 1 taken 1968 times.
60072 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1764 {
1765 1968 return false;
1766 }
1767
1768
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1769 {
1770 return false;
1771 }
1772
1773
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1774 {
1775 return false;
1776 }
1777
1778
1/2
✓ Branch 0 taken 58104 times.
✗ Branch 1 not taken.
58104 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1779 {
1780 return false;
1781 }
1782 58104 }
1783
1784
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1785 {
1786 return false;
1787 }
1788
1789
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1790 {
1791 return false;
1792 }
1793
1794
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1795 {
1796 return false;
1797 }
1798
1799
1/2
✓ Branch 0 taken 87156 times.
✗ Branch 1 not taken.
87156 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1800 {
1801 return false;
1802 }
1803 87156 }
1804
1805
2/2
✓ Branch 0 taken 11298 times.
✓ Branch 1 taken 3228 times.
14526 if(i<2)
1806 {
1807
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.flags[i]!=b.flags[i])
1808 {
1809 return false;
1810 }
1811
1812
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1813 {
1814 return false;
1815 }
1816
1817
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1818 {
1819 return false;
1820 }
1821
1822
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1823 {
1824 return false;
1825 }
1826
1827
1/2
✓ Branch 0 taken 3228 times.
✗ Branch 1 not taken.
3228 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1828 {
1829 return false;
1830 }
1831 3228 }
1832
1833
2/2
✓ Branch 0 taken 9684 times.
✓ Branch 1 taken 4842 times.
14526 if(i<3)
1834 {
1835
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1836 {
1837 return false;
1838 }
1839
1840
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1841 {
1842 return false;
1843 }
1844
1845
1/2
✓ Branch 0 taken 4842 times.
✗ Branch 1 not taken.
4842 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1846 {
1847 return false;
1848 }
1849
1850
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4842 times.
4842 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1851 {
1852 return false;
1853 }
1854 4842 }
1855
1856
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1857 {
1858 return false;
1859 }
1860
1861
1/2
✓ Branch 0 taken 14526 times.
✗ Branch 1 not taken.
14526 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1862 {
1863 return false;
1864 }
1865 14526 }
1866
1867 1614 return true;
1868 3582 }
1869
1870 int32_t doortranslations_u[9][4]=
1871 {
1872 {37,38,53,54},
1873 {37,38,39,40},
1874 {37,38,55,56},
1875 {37,38,39,40},
1876 {37,38,53,54},
1877 {37,38,53,54},
1878 {37,38,53,54},
1879 {7,8,23,24},
1880 {7,8,41,42}
1881 };
1882
1883 int32_t doortranslations_d[9][4]=
1884 {
1885 {117,118,133,134},
1886 {135,136,133,134},
1887 {119,120,133,134},
1888 {135,136,133,134},
1889 {117,118,133,134},
1890 {117,118,133,134},
1891 {117,118,133,134},
1892 {151,152,167,168},
1893 {137,138,167,168},
1894 };
1895
1896 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1897 int32_t doortranslations_l[9][6]=
1898 {
1899 {66,67,82,83,98,99},
1900 {66,68,82,84,98,100},
1901 {66,69,82,85,98,101},
1902 {66,68,82,84,98,100},
1903 {66,67,82,83,98,99},
1904 {66,67,82,83,98,99},
1905 {66,67,82,83,98,99},
1906 {64,65,80,81,96,97},
1907 {64,65,80,114,96,97},
1908 };
1909
1910 int32_t doortranslations_r[9][6]=
1911 {
1912
1913 {76,77,92,93,108,109},
1914 {75,77,91,93,107,109},
1915 {74,77,90,93,106,109},
1916 {75,77,91,93,107,109},
1917 {76,77,92,93,108,109},
1918 {76,77,92,93,108,109},
1919 {76,77,92,93,108,109},
1920 {78,79,94,95,110,111},
1921 {78,79,125,95,110,111},
1922 };
1923
1924 314668 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1925 {
1926 314668 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1927 }
1928
1929 308180 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1930 {
1931 //these are here to bypass compiler warnings about unused arguments
1932 308180 map=map;
1933 308180 scr=scr;
1934 308180 pos=pos;
1935
1936 //what does this function do?
1937 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1938 308180 return 2;
1939 }
1940
1941 7072 int32_t MakeDoors(int32_t map, int32_t scr)
1942 {
1943
2/2
✓ Branch 0 taken 5450 times.
✓ Branch 1 taken 1622 times.
7072 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1944 {
1945 5450 return 0;
1946 }
1947
1948 DoorComboSet tempdcs;
1949 1622 memset(&tempdcs, 0, sizeof(DoorComboSet));
1950
1951 //up
1952
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1953 {
1954
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1955 {
1956 58392 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1957 58392 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1958 58392 }
1959 14598 }
1960
1961 1622 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1962 1622 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1963 1622 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1964 1622 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1965 1622 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1966 1622 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1967
1968 //down
1969
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1970 {
1971
2/2
✓ Branch 0 taken 58392 times.
✓ Branch 1 taken 14598 times.
72990 for(int32_t j=0; j<4; j++)
1972 {
1973 58392 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1974 58392 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1975 58392 }
1976 14598 }
1977
1978 1622 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1979
1980 1622 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1981 1622 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1982 1622 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1983 1622 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1984 1622 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1985
1986 //left
1987 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1988
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
1989 {
1990
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
1991 {
1992 87588 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1993 87588 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1994 87588 }
1995 14598 }
1996
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
1998 {
1999 if((j!=2)&&(j!=3))
2000 {
2001 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
2002 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
2003 }
2004 }
2005
2006 1622 tempdcs.bombdoorcombo_l[0]=0;
2007 1622 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
2008 1622 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
2009 1622 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
2010 1622 tempdcs.bombdoorcombo_l[2]=0;
2011 1622 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
2012 1622 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
2013 1622 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
2014
2015 //right
2016
2/2
✓ Branch 0 taken 14598 times.
✓ Branch 1 taken 1622 times.
16220 for(int32_t i=0; i<9; i++)
2017 {
2018
2/2
✓ Branch 0 taken 87588 times.
✓ Branch 1 taken 14598 times.
102186 for(int32_t j=0; j<6; j++)
2019 {
2020 87588 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
2021 87588 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
2022 87588 }
2023 14598 }
2024
2025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1622 times.
1622 for(int32_t j=0; j>6; j++)
2026 {
2027 if((j!=2)&&(j!=3))
2028 {
2029 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
2030 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
2031 }
2032 }
2033
2034 1622 tempdcs.bombdoorcombo_r[0]=0;
2035 1622 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
2036 1622 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
2037 1622 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
2038 1622 tempdcs.bombdoorcombo_r[2]=0;
2039 1622 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
2040 1622 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
2041 1622 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
2042
2043 int32_t k;
2044
2045
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 3582 times.
3590 for(k=0; k<door_combo_set_count; k++)
2046 {
2047
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 1968 times.
3582 if(DoorComboSets[k]==tempdcs)
2048 {
2049 1614 break;
2050 }
2051 1968 }
2052
2053
2/2
✓ Branch 0 taken 1614 times.
✓ Branch 1 taken 8 times.
1622 if(k==door_combo_set_count)
2054 {
2055 8 DoorComboSets[k]=tempdcs;
2056 8 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
2057 8 ++door_combo_set_count;
2058 8 }
2059
2060 1622 return k;
2061 /*
2062 doorcombo_u[9][4];
2063 doorcset_u[9][4];
2064 doorcombo_d[9][4];
2065 doorcset_d[9][4];
2066 doorcombo_l[9][6];
2067 doorcset_l[9][6];
2068 doorcombo_r[9][6];
2069 doorcset_r[9][6];
2070 bombdoorcombo_u[2];
2071 bombdoorcset_u[2];
2072 bombdoorcombo_d[2];
2073 bombdoorcset_d[2];
2074 bombdoorcombo_l[3];
2075 bombdoorcset_l[3];
2076 bombdoorcombo_r[3];
2077 bombdoorcset_r[3];
2078 walkthroughcombo[4];
2079 walkthroughcset[4];
2080 */
2081 7072 }
2082
2083 905216 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
2084 {
2085 905216 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
2086 }
2087
2088 905216 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
2089 {
2090
2091 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
2092 }
2093
2094 905216 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
2095 {
2096 905216 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
2097 }
2098
2099
2100 16 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
2101 {
2102 char temp_pwd[30];
2103 16 memset(temp_pwd,0,30);
2104
2105
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(pwdkey!=0)
2106 {
2107 16 memcpy(temp_pwd,encrypted_pwd,30);
2108 16 temp_pwd[29]=0;
2109
2110
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 16 times.
496 for(int32_t i=0; i<30; i++)
2111 {
2112 480 temp_pwd[i] -= pwdkey;
2113 480 int32_t t=pwdkey>>15;
2114 480 pwdkey = (pwdkey<<1)+t;
2115 480 }
2116 16 }
2117
2118 16 memcpy(pwd,temp_pwd,30);
2119 16 }
2120
2121
2122 92 bool devpwd()
2123 {
2124 92 return true; // TODO !!
2125 #ifdef _DEBUG
2126 return true;
2127 #endif
2128 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio);
2129 }
2130 bool check_questpwd(zquestheader *Header, char *pwd)
2131 {
2132 #if DEVLEVEL > 3
2133 return true;
2134 #endif
2135
2136 if (devpwd()) return true;
2137 if ( (!strcmp(pwd, (char*)clavio)) ) return true;
2138 cvs_MD5Context ctx;
2139 uint8_t md5sum[16];
2140
2141 cvs_MD5Init(&ctx);
2142 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
2143 cvs_MD5Final(md5sum, &ctx);
2144
2145 return (memcmp(Header->pwd_hash,md5sum,16)==0);
2146 }
2147
2148 121 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2149 {
2150 121 zprint2("\n");
2151 121 zprint2("[ZQUEST CREATOR METADATA]\n");
2152
1/2
✓ Branch 0 taken 121 times.
✗ Branch 1 not taken.
121 if(qst_num < moduledata.max_quest_files)
2153 zprint2("Loading module quest %d\n", qst_num+1);
2154
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 if(path) zprint2("Loading '%s'\n", path);
2155
2/2
✓ Branch 0 taken 117 times.
✓ Branch 1 taken 4 times.
121 if ( tempheader.new_version_id_main > 0 )
2156 {
2157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 117 times.
117 if(tempheader.new_version_id_fourth > 0)
2158 zprint2("Last saved in ZQuest Version %d.%d.%d.%d ",
2159 tempheader.new_version_id_main,tempheader.new_version_id_second,
2160 tempheader.new_version_id_third,tempheader.new_version_id_fourth);
2161 117 else zprint2("Last saved in ZQuest Version: %d.%d.%d ",
2162 117 tempheader.new_version_id_main,tempheader.new_version_id_second,
2163 117 tempheader.new_version_id_third);
2164 117 }
2165 else
2166 {
2167
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
4 switch ( tempheader.zelda_version )
2168 {
2169 case 0x255:
2170 {
2171 zprint2("Last saved in ZQuest Version: 2.55.0, %s: %d", tempheader.getAlphaStr(), tempheader.getAlphaVer());
2172 break;
2173 }
2174 case 0x254:
2175 {
2176 zprint2("Last saved in ZQuest Version: 2.54.0, Alpha Build ID: %d", tempheader.build);
2177 break;
2178 }
2179 case 0x250:
2180 {
2181 switch(tempheader.build)
2182 {
2183 case 19:
2184 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 1"); break;
2185 case 20:
2186 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 2"); break;
2187 case 21:
2188 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 3"); break;
2189 case 22:
2190 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 4"); break;
2191 case 23:
2192 zprint2("Last saved in ZQuest Version: 2.50.0, Gamma 5"); break;
2193 case 24:
2194 zprint2("Last saved in ZQuest Version: 2.50.0, Release"); break;
2195 case 25:
2196 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 1"); break;
2197 case 26:
2198 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 2"); break;
2199 case 27:
2200 zprint2("Last saved in ZQuest Version: 2.50.1, Gamma 3"); break;
2201 case 28:
2202 zprint2("Last saved in ZQuest Version: 2.50.1, Release"); break;
2203 case 29:
2204 zprint2("Last saved in ZQuest Version: 2.50.2, Release"); break;
2205 case 30:
2206 zprint2("Last saved in ZQuest Version: 2.50.3, Gamma 1"); break;
2207 case 31:
2208 zprint2("Last saved in ZQuest Version: 2.53.0, Prior to Gamma 3"); break;
2209 case 32:
2210 zprint2("Last saved in ZQuest Version: 2.53.0"); break;
2211 case 33:
2212 zprint2("Last saved in ZQuest Version: 2.53.1"); break;
2213 default:
2214 zprint2("Last saved in ZQuest Version: %x, Build %d", tempheader.zelda_version,tempheader.build); break;
2215
2216 }
2217 break;
2218 }
2219
2220 case 0x211:
2221 {
2222 zprint2("Last saved in ZQuest Version: 2.11, Beta %d", tempheader.build); break;
2223 }
2224 case 0x210:
2225 {
2226 zprint2("Last saved in ZQuest Version: 2.10.x");
2227 if ( tempheader.build ) zprint2("Beta/Build %d\n", tempheader.build);
2228 break;
2229 }
2230 /* These versions cannot be handled here; they will be incorrect at this time. -Z
2231 case 0x193:
2232 {
2233 zprint2("Last saved in ZQuest Version: 1.93, Beta %d\n", tempheader.build); break;
2234 }
2235 case 0x192:
2236 {
2237 zprint2("Last saved in ZQuest Version: 1.92, Beta %d\n", tempheader.build); break;
2238 }
2239 case 0x190:
2240 {
2241 zprint2("Last saved in ZQuest Version: 1.90, Beta/Build %d\n", tempheader.build); break;
2242 }
2243 case 0x184:
2244 {
2245 zprint2("Last saved in ZQuest Version: 1.84, Beta/Build %d\n", tempheader.build); break;
2246 }
2247 case 0x183:
2248 {
2249 zprint2("Last saved in ZQuest Version: 1.83, Beta/Build %d\n", tempheader.build); break;
2250 }
2251 case 0x180:
2252 {
2253 zprint2("Last saved in ZQuest Version: 1.80, Beta/Build %d\n", tempheader.build); break;
2254 }
2255 default:
2256 {
2257 zprint2("Last saved in ZQuest Version: %x, Beta %d\n", tempheader.zelda_version,tempheader.build); break;
2258 }
2259 */
2260 }
2261 }
2262
3/4
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 28 times.
121 if(!tempheader.is_legacy() && tempheader.getAlphaVer())
2263 28 zprint2("%s\n", tempheader.getAlphaVerStr());
2264 93 else zprint2("\n");
2265
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2266
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2267
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2268
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2269
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 117 times.
121 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2270
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 28 times.
121 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2271 121 zprint2("\n");
2272 121 }
2273
2274 129 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2275 {
2276 int32_t dummy;
2277 zquestheader tempheader;
2278 char dummybuf[80];
2279 byte temp_map_count;
2280 byte temp_midi_flags[MIDIFLAGS_SIZE];
2281 word version;
2282 char temp_pwd[30], temp_pwd2[30];
2283 int16_t temp_pwdkey;
2284 cvs_MD5Context ctx;
2285 129 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2286 129 memset(&tempheader, 0, sizeof(tempheader));
2287 129 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2288
2289
2290
2291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2292 {
2293 Z_message("Unable to read header string\n");
2294 return qe_invalid;
2295 }
2296
2297 // check header
2298
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2299 {
2300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2301 {
2302 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2303 return qe_invalid;
2304 }
2305 4 }
2306
2307 129 int32_t templatepath_len=0;
2308
2309 129 tempheader.external_zinfo = false;
2310 129 read_zinfo = false;
2311
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2312 {
2313 byte padding;
2314
2315
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2316 {
2317 return qe_invalid;
2318 }
2319
2320
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.zelda_version,f))
2321 {
2322 return qe_invalid;
2323 }
2324
2325 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2326
2327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version > ZELDA_VERSION)
2328 {
2329 return qe_version;
2330 }
2331
2332 4 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2333
2334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(strcmp(tempheader.id_str,QH_IDSTR))
2335 {
2336 return qe_invalid;
2337 }
2338
2339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(bad_version(tempheader.zelda_version))
2340 {
2341 return qe_obsolete;
2342 }
2343
2344
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&tempheader.internal,f))
2345 {
2346 return qe_invalid;
2347 }
2348
2349
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.quest_number,f))
2350 {
2351 return qe_invalid;
2352 }
2353
2354 4 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2355
2356
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[0],2,f))
2357 {
2358 return qe_invalid;
2359 }
2360
2361
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&temp_map_count,f))
2362 {
2363 return qe_invalid;
2364 }
2365
2366 4 FFCore.quest_format[qMapCount] = temp_map_count;
2367
2368
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.old_str_count,f))
2369 {
2370 return qe_invalid;
2371 }
2372
2373
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2374 {
2375 return qe_invalid;
2376 }
2377
2378
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_midi_flags,4,f))
2379 {
2380 return qe_invalid;
2381 }
2382
2383
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2384 {
2385 return qe_invalid;
2386 }
2387
2388
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,14,f))
2389 {
2390 return qe_invalid;
2391 }
2392
2393
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[2],2,f))
2394 {
2395 return qe_invalid;
2396 }
2397
2398
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&dummybuf,f))
2399 {
2400 return qe_invalid;
2401 }
2402
2403
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.version,9,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2409 {
2410 return qe_invalid;
2411 }
2412 // These fields are expected to end in null bytes!
2413 4 tempheader.title[sizeof(tempheader.title)-1] = 0;
2414
2415
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2416 {
2417 return qe_invalid;
2418 }
2419 4 tempheader.author[sizeof(tempheader.author)-1] = 0;
2420
2421
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&padding,f))
2422 {
2423 return qe_invalid;
2424 }
2425
2426
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_igetw(&temp_pwdkey,f))
2427 {
2428 return qe_invalid;
2429 }
2430
2431
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(temp_pwd,30,f))
2432 {
2433 return qe_invalid;
2434 }
2435
2436 4 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2437 4 cvs_MD5Init(&ctx);
2438 4 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2439 4 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2440
2441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2442 {
2443 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2444 // Not anymore...
2445 memset(tempheader.minver,0,17);
2446 tempheader.build=0;
2447 tempheader.use_keyfile=0;
2448 memset(tempheader.old_foo, 0, 9);
2449 }
2450 else
2451 {
2452
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(tempheader.minver,9,f))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.build,f))
2458 {
2459 return qe_invalid;
2460 }
2461
2462 4 FFCore.quest_format[vBuild] = tempheader.build;
2463
2464
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tempheader.use_keyfile,f))
2465 {
2466 return qe_invalid;
2467 }
2468
2469
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(dummybuf,9,f))
2470 {
2471 return qe_invalid;
2472 }
2473 } // starting at minver
2474
2475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2476 {
2477 memset(&quest_rules[4],0,16); // word rules3..rules10
2478 }
2479 else
2480 {
2481
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2482 {
2483 return qe_invalid; // starting at rules3
2484 }
2485
2486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(tempheader.zelda_version <= 0x190)
2487 {
2488 4 set_qr(qr_MEANPLACEDTRAPS,0);
2489 4 }
2490 }
2491
2492
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2493 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2494 {
2495 4 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2496 4 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2497 4 set_qr(qr_BRKBLSHLDS_DEP,1);
2498 4 }
2499
2500
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2501 {
2502 byte *mf=temp_midi_flags;
2503
2504 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2505 {
2506 mf=(byte*)dummybuf;
2507 }
2508
2509 if(!pfread(mf,32,f)) // read new header additions
2510 {
2511 return qe_invalid; // starting at foo2
2512 }
2513
2514 if(!pfread(dummybuf,18,f)) // read new header additions
2515 {
2516 return qe_invalid; // starting at foo2
2517 }
2518 }
2519
2520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2521 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2522 {
2523 4 memset(tempheader.templatepath,0,2048);
2524 4 }
2525 else
2526 {
2527 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2528 {
2529 return qe_invalid;
2530 }
2531 }
2532
2533
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((tempheader.zelda_version < 0x192)||
2534 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2535 {
2536 4 tempheader.use_keyfile=0;
2537 4 }
2538 4 }
2539 else
2540 {
2541 //section id
2542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_mgetl(&dummy,f))
2543 {
2544 return qe_invalid;
2545 }
2546
2547 //section version info
2548
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
2549 {
2550 return qe_invalid;
2551 }
2552
2553 125 FFCore.quest_format[vHeader] = version;
2554
2555
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
2556 {
2557 return qe_invalid;
2558 }
2559
2560 //section size
2561
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
2562 {
2563 return qe_invalid;
2564 }
2565
2566 //finally... section data
2567
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.zelda_version,f))
2568 {
2569 return qe_invalid;
2570 }
2571
2572 125 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2573
2574 //do some quick checking...
2575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(tempheader.zelda_version > ZELDA_VERSION)
2576 {
2577 return qe_version;
2578 }
2579
2580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2581 {
2582 return qe_invalid;
2583 }
2584
2585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(bad_version(tempheader.zelda_version))
2586 {
2587 return qe_obsolete;
2588 }
2589
2590
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.build,f))
2591 {
2592 return qe_invalid;
2593 }
2594
2595 125 FFCore.quest_format[vBuild] = tempheader.build;
2596
2597
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(version<3)
2598 {
2599
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!pfread(temp_pwd,30,f))
2600 {
2601 return qe_invalid;
2602 }
2603
2604
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&temp_pwdkey,f))
2605 {
2606 return qe_invalid;
2607 }
2608
2609 12 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2610 12 cvs_MD5Init(&ctx);
2611 12 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2612 12 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2613 12 }
2614 else
2615 {
2616
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2617 {
2618 return qe_invalid;
2619 }
2620 }
2621
2622
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&tempheader.internal,f))
2623 {
2624 return qe_invalid;
2625 }
2626
2627
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.quest_number,f))
2628 {
2629 return qe_invalid;
2630 }
2631
2632 125 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2633
2634 125 size_t versz = version < 8 ? 9 : 16;
2635
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.version,versz,f))
2636 {
2637 return qe_invalid;
2638 }
2639
2640 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2641 //needs to be copied as char[9] or stored as a s.str
2642
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.minver,versz,f))
2643 {
2644 return qe_invalid;
2645 }
2646
2647 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2648
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2649 {
2650 return qe_invalid;
2651 }
2652 125 tempheader.title[sizeof(tempheader.title)-1] = 0;
2653
2654
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2655 {
2656 return qe_invalid;
2657 }
2658 125 tempheader.author[sizeof(tempheader.author)-1] = 0;
2659
2660
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.use_keyfile,f))
2661 {
2662 return qe_invalid;
2663 }
2664
2665 /*
2666 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2667 {
2668 return qe_invalid;
2669 }
2670 */
2671
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2672 {
2673 return qe_invalid;
2674 }
2675
2676
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(&dummybuf,4,f))
2677 {
2678 return qe_invalid;
2679 }
2680
2681
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2682 {
2683 return qe_invalid;
2684 }
2685
2686
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(dummybuf,14,f))
2687 {
2688 return qe_invalid;
2689 }
2690
2691 125 templatepath_len=sizeof(tempheader.templatepath);
2692
2693
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(version==1)
2694 {
2695 12 templatepath_len=280;
2696 12 }
2697
2698
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(tempheader.templatepath,templatepath_len,f))
2699 {
2700 return qe_invalid;
2701 }
2702
2703
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_getc(&temp_map_count,f))
2704 {
2705 return qe_invalid;
2706 }
2707
2708
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version>=4)
2709 {
2710
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_main,f))
2711 {
2712 return qe_invalid;
2713 }
2714
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_second,f))
2715 {
2716 return qe_invalid;
2717 }
2718
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_third,f))
2719 {
2720 return qe_invalid;
2721 }
2722
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2723 {
2724 return qe_invalid;
2725 }
2726
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2727 {
2728 return qe_invalid;
2729 }
2730
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_beta,f))
2731 {
2732 return qe_invalid;
2733 }
2734
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2735 {
2736 return qe_invalid;
2737 }
2738
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.new_version_id_release,f))
2739 {
2740 return qe_invalid;
2741 }
2742
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2743 {
2744 return qe_invalid;
2745 }
2746
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_month,f))
2747 {
2748 return qe_invalid;
2749 }
2750
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_day,f))
2751 {
2752 return qe_invalid;
2753 }
2754
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2755 {
2756 return qe_invalid;
2757 }
2758
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2759 {
2760 return qe_invalid;
2761 }
2762
2763
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_devsig,256,f))
2764 {
2765 return qe_invalid;
2766 }
2767
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2768 strcpy(tempheader.new_version_devsig, "EmilyV99");
2769
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilername,256,f))
2770 {
2771 return qe_invalid;
2772 }
2773
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.new_version_compilerversion,256,f))
2774 {
2775 return qe_invalid;
2776 }
2777
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.product_name,1024,f))
2778 {
2779 return qe_invalid;
2780 }
2781
2782
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&tempheader.compilerid,f))
2783 {
2784 return qe_invalid;
2785 }
2786
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2787 {
2788 return qe_invalid;
2789 }
2790
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2791 {
2792 return qe_invalid;
2793 }
2794
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2795 {
2796 return qe_invalid;
2797 }
2798
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2799 {
2800 return qe_invalid;
2801 }
2802
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&tempheader.developerid,f))
2803 {
2804 return qe_invalid;
2805 }
2806
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.made_in_module_name,1024,f))
2807 {
2808 return qe_invalid;
2809 }
2810
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_datestamp,256,f))
2811 {
2812 return qe_invalid;
2813 }
2814
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(tempheader.build_timestamp,256,f))
2815 {
2816 return qe_invalid;
2817 }
2818 36 }
2819 else // <4
2820 {
2821 89 tempheader.new_version_id_main = 0;
2822 89 tempheader.new_version_id_second = 0;
2823 89 tempheader.new_version_id_third = 0;
2824 89 tempheader.new_version_id_fourth = 0;
2825 89 tempheader.new_version_id_alpha = 0;
2826 89 tempheader.new_version_id_beta = 0;
2827 89 tempheader.new_version_id_gamma = 0;
2828 89 tempheader.new_version_id_release = 0;
2829 89 tempheader.new_version_id_date_year = 0;
2830 89 tempheader.new_version_id_date_month = 0;
2831 89 tempheader.new_version_id_date_day = 0;
2832 89 tempheader.new_version_id_date_hour = 0;
2833 89 tempheader.new_version_id_date_minute = 0;
2834
2835 89 memset(tempheader.new_version_devsig, 0, 256);
2836 89 memset(tempheader.new_version_compilername, 0, 256);
2837 89 memset(tempheader.new_version_compilerversion, 0, 256);
2838 89 memset(tempheader.product_name, 0, 1024);
2839 89 strcpy(tempheader.product_name, "ZQuest Creator Suite");
2840
2841 89 tempheader.compilerid = 0;
2842 89 tempheader.compilerversionnumber_first = 0;
2843 89 tempheader.compilerversionnumber_second = 0;
2844 89 tempheader.compilerversionnumber_third = 0;
2845 89 tempheader.compilerversionnumber_fourth = 0;
2846 89 tempheader.developerid = 0;
2847
2848 89 memset(tempheader.made_in_module_name, 0, 1024);
2849 89 memset(tempheader.build_datestamp, 0, 256);
2850 89 memset(tempheader.build_timestamp, 0, 256);
2851 }
2852
2853
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( version >= 5 )
2854 {
2855
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!pfread(tempheader.build_timezone,6,f))
2856 {
2857 return qe_invalid;
2858 }
2859 36 }
2860 else // < 5
2861 {
2862 89 memset(tempheader.build_timezone, 0, 6);
2863 }
2864
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( version >= 6 )
2865 {
2866 byte b;
2867
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&b,f))
2868 {
2869 return qe_invalid;
2870 }
2871 36 tempheader.external_zinfo = b?true:false;
2872 36 read_zinfo = true;
2873 36 }
2874
2875
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(version >= 7)
2876 {
2877
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2878 {
2879 return qe_invalid;
2880 }
2881 36 }
2882 else
2883 {
2884 89 tempheader.new_version_is_nightly = false;
2885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(tempheader.zelda_version < 0x255)
2886 {
2887
2/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12 times.
89 switch(tempheader.zelda_version)
2888 {
2889 case 0x254:
2890 tempheader.new_version_id_main = 2;
2891 tempheader.new_version_id_second = 54;
2892 break;
2893 case 0x250:
2894
6/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 22 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✓ Branch 10 taken 5 times.
✓ Branch 11 taken 24 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 15 times.
✓ Branch 14 taken 10 times.
✓ Branch 15 taken 1 times.
77 switch(tempheader.build)
2895 {
2896 case 19:
2897 tempheader.new_version_id_main = 2;
2898 tempheader.new_version_id_second = 50;
2899 tempheader.new_version_id_gamma = 1;
2900 break;
2901 case 20:
2902 tempheader.new_version_id_main = 2;
2903 tempheader.new_version_id_second = 50;
2904 tempheader.new_version_id_gamma = 2;
2905 break;
2906 case 21:
2907 tempheader.new_version_id_main = 2;
2908 tempheader.new_version_id_second = 50;
2909 tempheader.new_version_id_gamma = 3;
2910 break;
2911 case 22:
2912 tempheader.new_version_id_main = 2;
2913 tempheader.new_version_id_second = 50;
2914 tempheader.new_version_id_gamma = 4;
2915 break;
2916 case 23:
2917 tempheader.new_version_id_main = 2;
2918 tempheader.new_version_id_second = 50;
2919 tempheader.new_version_id_gamma = 5;
2920 break;
2921 case 24:
2922 22 tempheader.new_version_id_main = 2;
2923 22 tempheader.new_version_id_second = 50;
2924 22 tempheader.new_version_id_release = -1;
2925 22 break;
2926 case 25:
2927 tempheader.new_version_id_main = 2;
2928 tempheader.new_version_id_second = 50;
2929 tempheader.new_version_id_third = 1;
2930 tempheader.new_version_id_gamma = 1;
2931 break;
2932 case 26:
2933 tempheader.new_version_id_main = 2;
2934 tempheader.new_version_id_second = 50;
2935 tempheader.new_version_id_third = 1;
2936 tempheader.new_version_id_gamma = 2;
2937 break;
2938 case 27:
2939 tempheader.new_version_id_main = 2;
2940 tempheader.new_version_id_second = 50;
2941 tempheader.new_version_id_third = 1;
2942 tempheader.new_version_id_gamma = 3;
2943 break;
2944 case 28:
2945 5 tempheader.new_version_id_main = 2;
2946 5 tempheader.new_version_id_second = 50;
2947 5 tempheader.new_version_id_third = 1;
2948 5 tempheader.new_version_id_release = -1;
2949 5 break;
2950 case 29:
2951 24 tempheader.new_version_id_main = 2;
2952 24 tempheader.new_version_id_second = 50;
2953 24 tempheader.new_version_id_third = 2;
2954 24 tempheader.new_version_id_release = -1;
2955 24 break;
2956 case 30:
2957 tempheader.new_version_id_main = 2;
2958 tempheader.new_version_id_second = 50;
2959 tempheader.new_version_id_third = 3;
2960 tempheader.new_version_id_gamma = 1;
2961 break;
2962 case 31:
2963 15 tempheader.new_version_id_main = 2;
2964 15 tempheader.new_version_id_second = 53;
2965 15 tempheader.new_version_id_gamma = -1;
2966 15 break;
2967 case 32:
2968 10 tempheader.new_version_id_main = 2;
2969 10 tempheader.new_version_id_second = 53;
2970 10 tempheader.new_version_id_release = -1;
2971 10 break;
2972 case 33:
2973 1 tempheader.new_version_id_main = 2;
2974 1 tempheader.new_version_id_second = 53;
2975 1 tempheader.new_version_id_third = 1;
2976 1 break;
2977 }
2978 77 break;
2979
2980 case 0x211:
2981 tempheader.new_version_id_main = 2;
2982 tempheader.new_version_id_second = 11;
2983 tempheader.new_version_id_beta = tempheader.build;
2984 break;
2985 case 0x210:
2986 12 tempheader.new_version_id_main = 2;
2987 12 tempheader.new_version_id_second = 10;
2988 12 tempheader.new_version_id_beta = tempheader.build;
2989 12 break;
2990 }
2991 89 }
2992 }
2993
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(printmetadata || __isZQuest)
2994 {
2995 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2996 }
2997 }
2998
2999 //{ Version Warning
3000 129 int32_t vercmp = tempheader.compareVer();
3001 129 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), ALPHA_STATE);
3002 129 int32_t avercmp = compare(tempheader.getAlphaVer(), ALPHA_VER);
3003
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
165 if(vercmp > 0 || (!vercmp &&
3004
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 (astatecmp > 0 || (!astatecmp &&
3005 36 avercmp > 0))))
3006 {
3007 bool r = true;
3008 if(loadquest_report)
3009 {
3010 enter_sys_pal();
3011 AlertDialog("Quest saved in newer version",
3012 "This quest was last saved in a newer version of ZQuest."
3013 " Attempting to load this quest may not work correctly; to"
3014 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
3015 "\n\nWould you like to continue loading anyway? (Not recommended)",
3016 [&](bool ret,bool)
3017 {
3018 r = ret;
3019 }).show();
3020 exit_sys_pal();
3021 }
3022 if(!r)
3023 return qe_silenterr;
3024 }
3025
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 else if(tempheader.compareDate() > 0)
3026 {
3027 bool r = true;
3028 if(loadquest_report)
3029 {
3030 enter_sys_pal();
3031 AlertDialog("Quest saved in newer build",
3032 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
3033 " issues loading in this build."
3034 "\n{}"
3035 "\n\nWould you like to continue loading anyway?",
3036 tempheader.getVerCmpStr()),
3037 [&](bool ret,bool)
3038 {
3039 r = ret;
3040 }).show();
3041 exit_sys_pal();
3042 }
3043 if(!r)
3044 return qe_silenterr;
3045 }
3046 //}
3047
3048 129 read_ext_zinfo = tempheader.external_zinfo;
3049
3050 129 memcpy(Header, &tempheader, sizeof(tempheader));
3051 129 map_count=temp_map_count;
3052 129 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
3053
3054 129 return 0;
3055 129 }
3056
3057 131 int32_t readrules(PACKFILE *f, zquestheader *Header)
3058 {
3059 int32_t dummy;
3060 zquestheader tempheader;
3061 131 word s_version=0;
3062 131 dword compatrule_version=0;
3063
3064 131 memcpy(&tempheader, Header, sizeof(tempheader));
3065
3066
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 125 times.
131 if(tempheader.zelda_version >= 0x193)
3067 {
3068 //section version info
3069
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
3070 {
3071 return qe_invalid;
3072 }
3073
3074 125 FFCore.quest_format[vRules] = s_version;
3075
3076
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
3077 {
3078 return qe_invalid;
3079 }
3080
3081
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version > 16)
3082 {
3083
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&compatrule_version,f))
3084 {
3085 return qe_invalid;
3086 }
3087 36 }
3088 125 FFCore.quest_format[vCompatRule] = compatrule_version;
3089
3090 //section size
3091
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
3092 {
3093 return qe_invalid;
3094 }
3095
3096
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if ( s_version < 15 )
3097 {
3098 //finally... section data
3099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
3100 {
3101 return qe_invalid;
3102 }
3103 89 }
3104 else
3105 {
3106
3107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
3108 {
3109 return qe_invalid;
3110 }
3111
3112 }
3113 125 }
3114
3115 //al_trace("Rules version %d\n", s_version);
3116 //{ bunch of compat stuff
3117 131 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
3118
3119
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(s_version<2)
3120 {
3121 16 set_qr(14,0);
3122 16 set_qr(27,0);
3123 16 set_qr(28,0);
3124 16 set_qr(29,0);
3125 16 set_qr(30,0);
3126 16 set_qr(32,0);
3127 16 set_qr(36,0);
3128 16 set_qr(49,0);
3129 16 set_qr(50,0);
3130 16 set_qr(51,0);
3131 16 set_qr(68,0);
3132 16 set_qr(75,0);
3133 16 set_qr(76,0);
3134 16 set_qr(98,0);
3135 16 set_qr(110,0);
3136 16 set_qr(113,0);
3137 16 set_qr(116,0);
3138 16 set_qr(102,0);
3139 16 set_qr(132,0);
3140 16 }
3141
3142 //Now, do any updates...
3143
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
3144 {
3145 20 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
3146 20 set_qr(qr_REPLACEOPENDOORS, 1);
3147 20 set_qr(qr_OLDLENSORDER, 1);
3148 20 set_qr(qr_NOFAIRYGUYFIRES, 1);
3149 20 set_qr(qr_TRIGGERSREPEAT, 1);
3150 20 }
3151
3152
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3153 {
3154 8 set_qr(qr_WALLFLIERS,1);
3155 8 }
3156
3157
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
3158 {
3159 8 set_qr(qr_NOBOMBPALFLASH,1);
3160 8 }
3161
3162
5/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
3163 {
3164 8 set_qr(qr_NOSCROLLCONTINUE,1);
3165 8 }
3166
3167
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3168 {
3169 16 set_qr(qr_ARROWCLIP,1);
3170 16 }
3171
3172
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 12 times.
131 if(tempheader.zelda_version == 0x210)
3173 {
3174 12 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
3175 12 set_qr(qr_CMBCYCLELAYERS, 0);
3176 12 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
3177 12 }
3178
3179
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version <= 0x210)
3180 {
3181 16 set_qr(qr_OLDSTYLEWARP,1);
3182 16 set_qr(qr_210_WARPRETURN,1);
3183 16 }
3184
3185 //might not be correct
3186
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if(tempheader.zelda_version < 0x210)
3187 {
3188 4 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
3189 4 set_qr(qr_OLDTRIBBLES_DEP,1);
3190 4 set_qr(qr_OLDHOOKSHOTGRAB,1);
3191 4 }
3192
3193
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x211)
3194 {
3195 16 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3196 16 }
3197
3198
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 131 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
131 if(tempheader.zelda_version == 0x192 && tempheader.build == 163)
3199 {
3200 set_qr(qr_192b163_WARP,1);
3201 }
3202
3203
2/2
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 12 times.
131 if(tempheader.zelda_version == 0x210)
3204 {
3205 12 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3206 12 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3207 12 set_qr(qr_DMGCOMBOPRI, 0);
3208 12 }
3209
3210
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3211 {
3212 20 set_qr(qr_OLDPICKUP,1);
3213 20 }
3214
3215
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 2 times.
131 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3216 {
3217 20 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3218 20 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3219 20 }
3220
3221
2/2
✓ Branch 0 taken 115 times.
✓ Branch 1 taken 16 times.
131 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3222 {
3223 16 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3224 16 }
3225
3226
4/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 55 times.
✓ Branch 3 taken 22 times.
131 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3227 {
3228 22 set_qr(qr_PEAHATCLOCKVULN, 1);
3229 22 }
3230
3231
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3232 {
3233 20 set_qr(qr_OLD_DOORREPAIR, 1);
3234 20 }
3235
3236
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 2 times.
✓ Branch 5 taken 79 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3237 {
3238 20 set_qr(qr_OLD_SECRETMONEY, 1);
3239 20 }
3240
3241
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3242 {
3243 42 set_qr(qr_OLD_POTION_OR_HC, 1);
3244 42 }
3245
3246
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 24 times.
✓ Branch 5 taken 57 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3247 {
3248 42 set_qr(qr_OFFSCREENWEAPONS, 1);
3249 42 }
3250
3251 //Bombchu fix.
3252
2/2
✓ Branch 0 taken 54 times.
✓ Branch 1 taken 77 times.
131 if(tempheader.zelda_version == 0x250)
3253 {
3254
2/2
✓ Branch 0 taken 55 times.
✓ Branch 1 taken 22 times.
77 if ( tempheader.build == 24 ) //2.50.0
3255 {
3256 22 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3257 22 }
3258
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 5 times.
77 if ( tempheader.build == 28 ) //2.50.1
3259 {
3260 5 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3261 5 }
3262
2/2
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
77 if ( tempheader.build == 29 ) //2.50.2
3263 {
3264 24 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3265 24 }
3266
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if ( tempheader.build == 30 ) //2.50.3RC1
3267 {
3268 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3269 }
3270 77 }
3271
3272
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 29 times.
✓ Branch 5 taken 52 times.
131 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3273 {
3274 // qr_OFFSETEWPNCOLLISIONFIX
3275 // All 'official' quests need this disabled.
3276 // All 2.10 and lower quests need this enabled to preseve compatability.
3277 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3278
3279 //~Gleeok
3280 47 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3281
3282 // Broke in build 695
3283
3/4
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 27 times.
47 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3284 27 set_qr(qr_BROKENSTATUES, 1);
3285 43 }
3286
2/2
✓ Branch 0 taken 127 times.
✓ Branch 1 taken 4 times.
131 if (tempheader.zelda_version <= 0x190)
3287 {
3288 4 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3289 4 }
3290
9/10
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 54 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 37 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 1 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 36 times.
131 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3291 {
3292 94 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3293 94 }
3294
3295
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3296 {
3297 16 set_qr(qr_OLD_210_WATER, 1);
3298 16 }
3299
3300
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3301 {
3302 93 set_qr(qr_STEP_IS_FLOAT,0);
3303 93 }
3304
3305
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( tempheader.zelda_version < 0x250 )
3306 {
3307 16 set_qr(qr_8WAY_SHOT_SFX, 1);
3308 16 }
3309
3310
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 3)
3311 {
3312 16 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3313 16 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3314 16 }
3315
3316
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<4)
3317 {
3318 16 set_qr(10,0);
3319 16 }
3320
3321
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
3322 {
3323 16 set_qr(27,0);
3324 16 }
3325
3326
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<6)
3327 {
3328 16 set_qr(46,0);
3329 16 }
3330
3331
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<7) // January 2008
3332 {
3333 16 set_qr(qr_HEARTSREQUIREDFIX,0);
3334 16 set_qr(qr_PUSHBLOCKCSETFIX,1);
3335 16 }
3336
3337
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version<8)
3338 {
3339 16 set_qr(12, 0);
3340 16 }
3341 else
3342 {
3343 113 set_bit(deprecated_rules, 12, 0);
3344 }
3345
3346
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<9) // October 2008
3347 {
3348 16 set_qr(qr_NOROPE2FLASH_DEP,0);
3349 16 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3350 16 set_qr(qr_GHINI2BLINK_DEP,0);
3351 16 set_qr(qr_PHANTOMGHINI2_DEP,0);
3352 16 }
3353
3354
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<10) // December 2008
3355 {
3356 16 set_qr(qr_NOCLOCKS_DEP,0);
3357 16 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3358 16 }
3359
3360
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<11) // April 2009
3361 {
3362 16 set_qr(qr_SLOWENEMYANIM_DEP,0);
3363 16 }
3364
3365 // This served no purpose.
3366 // if(s_version<12) // December 2009
3367 // {
3368 // set_qr(qr_BRKBLSHLDS_DEP,0);
3369 // set_qr(qr_OLDTRIBBLES_DEP,0);
3370 // }
3371
3372 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3373
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 13)
3374 {
3375 16 set_qr(qr_SHOPCHEAT, 1);
3376 16 }
3377
3378 // Not entirely sure this is the best place for this...
3379 //2.50.2 bitmap offset fix
3380 129 memset(extra_rules, 0, EXTRARULES_SIZE);
3381
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 27 times.
✓ Branch 5 taken 50 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3382 {
3383 43 set_er(er_BITMAPOFFSET, 1);
3384 43 set_qr(qr_BITMAPOFFSETFIX, 1);
3385 43 }
3386 //required because quest templates also used this bit, although
3387 //it never did anything, before. -Z
3388
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 77 times.
129 if ( tempheader.zelda_version == 0x250 )
3389 {
3390
5/6
✓ Branch 0 taken 53 times.
✓ Branch 1 taken 24 times.
✓ Branch 2 taken 53 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 15 times.
✓ Branch 5 taken 38 times.
77 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3391 {
3392 39 set_er(er_BITMAPOFFSET, 0);
3393 39 set_qr(qr_BITMAPOFFSETFIX, 0);
3394 39 }
3395 77 }
3396
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if ( tempheader.zelda_version == 0x254 )
3397 {
3398 set_er(er_BITMAPOFFSET, 0);
3399 set_qr(qr_BITMAPOFFSETFIX, 0);
3400 }
3401
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
129 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3402 {
3403 set_er(er_BITMAPOFFSET, 0);
3404 set_qr(qr_BITMAPOFFSETFIX, 0);
3405 }
3406 //optimise fast drawing for older versions.
3407
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3408 {
3409 93 set_qr(qr_OLDSPRITEDRAWS, 1);
3410 93 }
3411 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3412 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3413 //older quests can set the rule by hand. We need a new qst.dat again.
3414
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3415 {
3416 set_qr(qr_OLDEWPNPARENT, 1);
3417 }
3418
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3419 {
3420 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3421 }
3422
4/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✓ Branch 3 taken 93 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3423 {
3424 set_qr(qr_OLDQUESTMISC, 1);
3425 }
3426
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3427 {
3428 93 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3429 93 set_qr(qr_OLDEWPNPARENT, 0);
3430 93 set_qr(qr_OLDQUESTMISC, 0);
3431 93 }
3432
3433 //item scripts continue to run
3434
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3435 {
3436 93 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3437 93 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3438 93 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3439 93 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3440 93 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3441 93 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3442 93 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3443 93 }
3444
3445
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3446 {
3447 93 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3448 93 }
3449
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3450 {
3451 93 set_qr(qr_TRACESCRIPTIDS, 0);
3452 93 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3453 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3454 93 set_qr(qr_PARSER_250DIVISION,1);
3455 93 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3456 93 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3457 93 set_qr(qr_PARSER_FORCE_INLINE,0);
3458 93 set_qr(qr_PARSER_BINARY_32BIT,0);
3459
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 2 times.
93 if ( get_qr(qr_SELECTAWPN) )
3460 {
3461 2 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3462 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3463 //Now they **do**, unless you disable that behaviour.
3464 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3465 //now enable the disable L/R item swap on load.
3466 2 }
3467
3468 93 }
3469
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3470 {
3471 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3472 93 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3473 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3474 //animations ending earlier than they should.
3475 93 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3476 //Enemies would ignore solidity on the top half of combos
3477 93 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3478 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3479 93 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3480 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3481 93 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3482 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3483 93 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3484 93 }
3485
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x255 )
3486 {
3487 93 set_qr(qr_NOFFCWAITDRAW, 1);
3488 93 set_qr(qr_NOITEMWAITDRAW, 1);
3489 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3490 93 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3491 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3492 93 }
3493
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3494 {
3495 93 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3496 93 }
3497
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3498 {
3499 93 set_qr(qr_OLD_PRINTF_ARGS, 1);
3500 93 }
3501
3502
3503
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3504 {
3505 93 set_qr(qr_BROKEN_RING_POWER, 1);
3506 93 }
3507
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3508 {
3509 93 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3510 93 }
3511
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3512 {
3513 93 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3514 93 }
3515
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3516 {
3517 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3518
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(get_qr(qr_SET_XBUTTON_ITEMS))
3519 set_qr(qr_SET_YBUTTON_ITEMS,1);
3520 93 }
3521
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3522 {
3523 93 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3524 93 }
3525
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3526 {
3527 93 set_qr(qr_OLD_CHEST_COLLISION,1);
3528 93 }
3529
3530
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( tempheader.zelda_version < 0x254 )
3531 {
3532 93 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3533 93 }
3534 //Sideview spikes in 2.50.0
3535
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 22 times.
✓ Branch 5 taken 55 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3536 {
3537 38 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3538 38 }
3539 //more 2.50 fixes -Z
3540
6/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 51 times.
✓ Branch 5 taken 26 times.
129 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3541 {
3542 67 set_qr(qr_MELEEMAGICCOST, 0);
3543 67 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3544 67 set_qr(qr_OLDMIRRORCOMBOS, 1);
3545 67 set_qr(qr_BROKENBOOKCOST, 1);
3546 67 set_qr(qr_BROKENCHARINTDRAWING, 1);
3547
3548 67 }
3549
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3550 {
3551 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3552 set_qr(qr_MELEEMAGICCOST, 1);
3553 }
3554
3555
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version < 0x193)
3556 {
3557 4 set_qr(qr_SHORTDGNWALK, 1);
3558 4 }
3559
3560
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(tempheader.zelda_version < 0x255)
3561 {
3562 93 set_qr(qr_OLDINFMAGIC, 1);
3563 93 }
3564
3565
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3566 {
3567 16 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3568 16 }
3569
3570
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3571 {
3572 93 set_qr(qr_OLD_F6,1);
3573 93 }
3574
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3575 {
3576 93 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3577 93 }
3578
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3579 {
3580 93 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3581 93 }
3582
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3583 {
3584 93 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3585 93 }
3586 //}
3587
3588
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3589 93 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3590
3591
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 2) //Old CSet2 Handling
3592 93 set_qr(qr_OLDCS2,1);
3593
3594
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3595 93 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3596
3597
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3598 93 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3599
3600
4/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 77 times.
129 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3601 77 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3602
3603
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3604 93 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3605
3606
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3607 93 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3608
3609
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3610 93 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3611
3612
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 9)
3613 {
3614 //Hardcoded BS Patras
3615 93 set_qr(qr_HARDCODED_BS_PATRA,1);
3616 //Hardcoded Patra Inner Eye offsets
3617 93 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3618 //Broken 'Big enemy' animation style
3619 93 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3620 //Broken Attribute 31/32
3621 93 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3622 93 }
3623
3624
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 10) //Shared candle use limits
3625 93 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3626
3627
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 11) //No cross-screen return points
3628 93 set_qr(qr_OLD_RESPAWN_POINTS,1);
3629
3630
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 12)
3631 {
3632 //Old fire trail duration
3633 93 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3634 //Old Intro String in Ganon Room Behavior
3635
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3636 93 else set_qr(qr_GANONINTRO,1);
3637 93 }
3638
3639
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
129 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3640 set_qr(qr_ANONE_NOANIM,1);
3641
3642
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 14) //Old Bridge Combo Behavior
3643 93 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3644
3645
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 15) //Broken Z3 Animation
3646 93 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3647
3648
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3649 93 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3650
3651
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 17)
3652 {
3653 //Old Quake/DrawYOffset behavior
3654 //set_qr(qr_OLD_DRAWOFFSET,1);
3655 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3656 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3657 93 }
3658
3659
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 18)
3660 {
3661 //Broken DrawScreen Derivative Functions
3662 93 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3663 //Scrolling Cancels Charge
3664 93 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3665 93 }
3666
3667
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3668 93 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3669
3670
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 20)
3671 93 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3672
3673
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 21)
3674 {
3675 93 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3676 93 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3677 93 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3678 93 set_qr(qr_OLD_BUG_NET,1);
3679 93 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3680 93 }
3681
3682
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 22)
3683 93 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3684
3685
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 23)
3686 93 set_qr(qr_OLD_HALF_MAGIC,1);
3687
3688
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 24)
3689 {
3690 93 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3691 93 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3692 93 }
3693
3694
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 25)
3695 {
3696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3697 93 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3698 93 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3699 93 }
3700
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 26)
3701 {
3702 93 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3703 93 set_qr(qr_POLVIRE_NO_SHADOW,1);
3704 93 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3705 93 }
3706
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3707 {
3708
2/2
✓ Branch 0 taken 27993 times.
✓ Branch 1 taken 93 times.
28086 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3709 27993 set_qr(q,0);
3710
2/2
✓ Branch 0 taken 10416 times.
✓ Branch 1 taken 93 times.
10509 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < QUESTRULES_NEW_SIZE*8; ++q)
3711 10416 set_qr(q,0);
3712 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3713 93 }
3714
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 28)
3715 95 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3716
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 29)
3717 95 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3718
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 30)
3719 {
3720 95 set_qr(qr_DECO_2_YOFFSET,1);
3721 95 set_qr(qr_SCREENSTATE_80s_BUG,1);
3722 95 }
3723
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 31)
3724 {
3725 95 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3726 95 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3727 95 }
3728
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 32)
3729 95 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3730
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 33)
3731 95 set_qr(qr_NO_LIFT_SPRITE,1);
3732
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(compatrule_version < 34)
3733 {
3734 95 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3735 95 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3736 95 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3737 95 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3738 95 }
3739
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 35)
3740 {
3741 96 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3742 96 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3743 96 }
3744
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 96 times.
129 if(compatrule_version < 36)
3745 96 set_qr(qr_OLD_SHALLOW_SFX,1);
3746
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 37)
3747 98 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3748
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 38)
3749 98 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3750
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 39)
3751 98 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3752
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(compatrule_version < 40)
3753 98 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3754
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 41)
3755 99 set_qr(qr_BROKENHITBY,1);
3756
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 42)
3757 99 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3758
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 43)
3759 99 set_qr(qr_OLD_BOMB_HITBOXES,1);
3760
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 99 times.
129 if(compatrule_version < 44)
3761 99 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3762
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 45)
3763 107 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3764
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 107 times.
129 if(compatrule_version < 46)
3765 107 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3766
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 47)
3767 {
3768 110 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3769 110 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3770 110 }
3771
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 48)
3772 110 set_qr(qr_OLD_GUY_HANDLING,1);
3773
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 110 times.
129 if(compatrule_version < 49)
3774 110 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(compatrule_version < 50)
3776 129 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(compatrule_version < 51)
3778 129 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3779
3780 129 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3781
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if (s_version < 16)
3782 93 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3783
3784 129 memcpy(Header, &tempheader, sizeof(tempheader));
3785
3786 129 return 0;
3787 129 }
3788
3789 1084440 void init_msgstr(MsgStr *str)
3790 {
3791 1084440 str->s = "";
3792 1084440 str->s.shrink_to_fit();
3793 1084440 str->nextstring=0;
3794 1084440 str->tile=0;
3795 1084440 str->cset=0;
3796 1084440 str->trans=false;
3797 1084440 str->font=font_zfont;
3798 1084440 str->y=32;
3799 1084440 str->sfx=18;
3800 1084440 str->listpos=0;
3801 1084440 str->x=24;
3802 1084440 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3803 1084440 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3804 1084440 str->hspace=0;
3805 1084440 str->vspace=0;
3806 1084440 str->stringflags=0;
3807 1084440 str->margins[up] = 8;
3808 1084440 str->margins[down] = 0;
3809 1084440 str->margins[left] = 8;
3810 1084440 str->margins[right] = 0;
3811 1084440 str->portrait_tile = 0;
3812 1084440 str->portrait_cset = 0;
3813 1084440 str->portrait_x = 0;
3814 1084440 str->portrait_y = 0;
3815 1084440 str->portrait_tw = 1;
3816 1084440 str->portrait_th = 1;
3817 1084440 str->shadow_type = 0;
3818 1084440 str->shadow_color = 0;
3819 1084440 str->drawlayer = 6;
3820 1084440 }
3821
3822 129 void init_msgstrings(int32_t start, int32_t end)
3823 {
3824
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if(end <= start || end-start > msg_strings_size)
3825 return;
3826
3827
2/2
✓ Branch 0 taken 1056768 times.
✓ Branch 1 taken 129 times.
1056897 for(int32_t i=start; i<end; i++)
3828 {
3829 1056768 init_msgstr(&MsgStrings[i]);
3830 1056768 MsgStrings[i].listpos=i;
3831 1056768 }
3832
3833
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(start==0)
3834 {
3835 129 MsgStrings[0].s = "(None)";
3836 129 MsgStrings[0].listpos = 0;
3837 129 }
3838 129 }
3839
3840 129 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3841 {
3842 129 MsgStr tempMsgString;
3843
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_msgstr(&tempMsgString);
3844
3845 129 word temp_msg_count=0;
3846 word temp_expansion[16];
3847 129 memset(temp_expansion, 0, 16*sizeof(word));
3848 129 char buf[8193] = {0};
3849
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
3850 {
3851 byte tempbyte;
3852 4 int32_t strings_to_read=0;
3853
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3854
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
3855 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3856 {
3857 4 strings_to_read=128;
3858 4 temp_msg_count=Header->old_str_count;
3859
3860 // Some sort of string count corruption seems to be common in old quests
3861
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(temp_msg_count>128)
3862 {
3863 temp_msg_count=128;
3864 }
3865 4 }
3866 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3867 {
3868 strings_to_read=255;
3869 temp_msg_count=Header->old_str_count;
3870 }
3871 else
3872 {
3873 if(!p_igetw(&temp_msg_count,f))
3874 {
3875 return qe_invalid;
3876 }
3877
3878 strings_to_read=temp_msg_count;
3879
3880 if(temp_msg_count >= msg_strings_size)
3881 {
3882 Z_message("Reallocating string buffer...\n");
3883
3884 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3885 // return qe_nomem;
3886
3887 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3888 delete[] MsgStrings;
3889 MsgStrings = new MsgStr[MAXMSGS];
3890 msg_strings_size = MAXMSGS;
3891 for(auto q = 0; q < msg_strings_size; ++q)
3892 {
3893 MsgStrings[q].clear();
3894 }
3895 }
3896 }
3897
3898 //reset the message strings
3899
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 init_msgstrings(0,msg_strings_size);
3900
3901
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t x=0; x<strings_to_read; x++)
3902 {
3903
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 init_msgstr(&tempMsgString);
3904 512 tempMsgString.listpos = x;
3905
3906
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!pfread(buf,73,f))
3907 {
3908 return qe_invalid;
3909 }
3910
3911 512 buf[74] = '\0';
3912
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 tempMsgString.s = buf;
3913
3914
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3915 {
3916 return qe_invalid;
3917 }
3918
3919
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
512 if((Header->zelda_version < 0x192)||
3920 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3921 {
3922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512 times.
512 tempMsgString.nextstring=tempbyte?x+1:0;
3923
3924
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3925 {
3926 return qe_invalid;
3927 }
3928
3929
2/4
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 512 times.
✗ Branch 3 not taken.
512 if(!p_getc(&tempbyte,f))
3930 {
3931 return qe_invalid;
3932 }
3933 512 }
3934 else
3935 {
3936 if(!p_igetw(&tempMsgString.nextstring,f))
3937 {
3938 return qe_invalid;
3939 }
3940
3941 if(!pfread(temp_expansion,32,f))
3942 {
3943 return qe_invalid;
3944 }
3945 }
3946
3947
1/2
✓ Branch 0 taken 512 times.
✗ Branch 1 not taken.
512 MsgStrings[x] = tempMsgString;
3948 512 }
3949 4 }
3950 else
3951 {
3952 int32_t dummy_int;
3953 word s_version;
3954 word s_cversion;
3955
3956 //section version info
3957
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
3958 {
3959 return qe_invalid;
3960 }
3961
3962 125 FFCore.quest_format[vStrings] = s_version;
3963
3964
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
3965 {
3966 return qe_invalid;
3967 }
3968
3969 //al_trace("Strings version %d\n", s_version);
3970 //section size
3971
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy_int,f))
3972 {
3973 return qe_invalid;
3974 }
3975
3976 //finally... section data
3977
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_msg_count,f))
3978 {
3979 return qe_invalid;
3980 }
3981
3982
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(temp_msg_count >= msg_strings_size)
3983 {
3984 Z_message("Reallocating string buffer...\n");
3985
3986 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3987 // return qe_nomem;
3988 delete[] MsgStrings;
3989 MsgStrings = new MsgStr[MAXMSGS];
3990 msg_strings_size = MAXMSGS;
3991 for(auto q = 0; q < msg_strings_size; ++q)
3992 {
3993 MsgStrings[q].clear();
3994 }
3995 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3996 }
3997
3998 //reset the message strings
3999
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 7)
4000
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
4001
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_msgstrings(0,msg_strings_size);
4002
4003 125 int32_t string_length=(s_version<2)?73:145;
4004
4005
2/2
✓ Branch 0 taken 27031 times.
✓ Branch 1 taken 125 times.
27156 for(int32_t i=0; i<temp_msg_count; i++)
4006 {
4007
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 init_msgstr(&tempMsgString);
4008 27031 tempMsgString.listpos = i;
4009
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 26139 times.
27031 if(s_version > 8)
4010 {
4011
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&string_length,f))
4012 {
4013 return qe_invalid;
4014 }
4015 892 }
4016
4017
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 27031 times.
27031 if (string_length < 0 || string_length > 8193)
4018 {
4019 return qe_invalid;
4020 }
4021
4022
2/2
✓ Branch 0 taken 26893 times.
✓ Branch 1 taken 138 times.
27031 if (string_length > 0)
4023 {
4024
2/4
✓ Branch 0 taken 26893 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26893 times.
✗ Branch 3 not taken.
26893 if (!pfread(buf, string_length, f))
4025 {
4026 return qe_invalid;
4027 }
4028 26893 }
4029 else
4030 {
4031 138 buf[0] = 0;
4032 }
4033
4034
2/4
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 27031 times.
✗ Branch 3 not taken.
27031 if(!p_igetw(&tempMsgString.nextstring,f))
4035 {
4036 return qe_invalid;
4037 }
4038
4039
2/2
✓ Branch 0 taken 19101 times.
✓ Branch 1 taken 7930 times.
27031 if(s_version<2)
4040 {
4041 19101 buf[72] = '\0';
4042
1/2
✓ Branch 0 taken 19101 times.
✗ Branch 1 not taken.
19101 tempMsgString.s = buf;
4043 19101 }
4044 else
4045 {
4046 // June 2008: A bug corrupted the last 4 chars of a string.
4047 // Discard these.
4048
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version<3)
4049 {
4050 for(int32_t j=140; j<144; j++)
4051 {
4052 buf[j] = '\0';
4053 }
4054 }
4055
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(string_length > 8192) string_length = 8192;
4056 7930 buf[string_length]='\0'; //Force-terminate
4057
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 tempMsgString.s = buf;
4058
4059
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if ( s_version >= 6 )
4060 {
4061
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.tile,f))
4062 {
4063 return qe_invalid;
4064 }
4065 892 }
4066 else
4067 {
4068
2/4
✓ Branch 0 taken 7038 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7038 times.
✗ Branch 3 not taken.
7038 if(!p_igetw(&tempMsgString.tile,f))
4069 {
4070 return qe_invalid;
4071 }
4072 }
4073
4074
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.cset,f))
4075 {
4076 return qe_invalid;
4077 }
4078
4079 byte dummy_char;
4080
4081
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
4082 {
4083 return qe_invalid;
4084 }
4085
4086 7930 tempMsgString.trans=dummy_char!=0;
4087
4088
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.font,f))
4089 {
4090 return qe_invalid;
4091 }
4092
4093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7930 times.
7930 if(s_version < 5)
4094 {
4095 if(!p_getc(&tempMsgString.y,f))
4096 {
4097 return qe_invalid;
4098 }
4099 }
4100 else
4101 {
4102
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.x,f))
4103 {
4104 return qe_invalid;
4105 }
4106
4107
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.y,f))
4108 {
4109 return qe_invalid;
4110 }
4111
4112
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.w,f))
4113 {
4114 return qe_invalid;
4115 }
4116
4117
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.h,f))
4118 {
4119 return qe_invalid;
4120 }
4121
4122
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.hspace,f))
4123 {
4124 return qe_invalid;
4125 }
4126
4127
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.vspace,f))
4128 {
4129 return qe_invalid;
4130 }
4131
4132
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.stringflags,f))
4133 {
4134 return qe_invalid;
4135 }
4136 }
4137
4138
2/2
✓ Branch 0 taken 7038 times.
✓ Branch 1 taken 892 times.
7930 if(s_version >= 7)
4139 {
4140
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 3568 times.
4460 for(int32_t q = 0; q < 4; ++q)
4141 {
4142
2/4
✓ Branch 0 taken 3568 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3568 times.
✗ Branch 3 not taken.
3568 if(!p_getc(&tempMsgString.margins[q],f))
4143 {
4144 return qe_invalid;
4145 }
4146 3568 }
4147
4148
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_igetl(&tempMsgString.portrait_tile,f))
4149 {
4150 return qe_invalid;
4151 }
4152
4153
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_cset,f))
4154 {
4155 return qe_invalid;
4156 }
4157
4158
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_x,f))
4159 {
4160 return qe_invalid;
4161 }
4162
4163
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_y,f))
4164 {
4165 return qe_invalid;
4166 }
4167
4168
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_tw,f))
4169 {
4170 return qe_invalid;
4171 }
4172
4173
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.portrait_th,f))
4174 {
4175 return qe_invalid;
4176 }
4177 892 }
4178
4179
2/2
✓ Branch 0 taken 892 times.
✓ Branch 1 taken 7038 times.
7930 if(s_version >= 8)
4180 {
4181
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_type,f))
4182 {
4183 return qe_invalid;
4184 }
4185
4186
2/4
✓ Branch 0 taken 892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 892 times.
✗ Branch 3 not taken.
892 if(!p_getc(&tempMsgString.shadow_color,f))
4187 {
4188 return qe_invalid;
4189 }
4190 892 }
4191
4192
2/2
✓ Branch 0 taken 775 times.
✓ Branch 1 taken 7155 times.
7930 if(s_version >= 10)
4193 {
4194
2/4
✓ Branch 0 taken 775 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 775 times.
✗ Branch 3 not taken.
775 if(!p_getc(&tempMsgString.drawlayer,f))
4195 {
4196 return qe_invalid;
4197 }
4198 775 }
4199
4200
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_getc(&tempMsgString.sfx,f))
4201 {
4202 return qe_invalid;
4203 }
4204
4205
1/2
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
7930 if(s_version>3)
4206 {
4207
2/4
✓ Branch 0 taken 7930 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7930 times.
✗ Branch 3 not taken.
7930 if(!p_igetw(&tempMsgString.listpos,f))
4208 {
4209 return qe_invalid;
4210 }
4211 7930 }
4212 }
4213
4214
1/2
✓ Branch 0 taken 27031 times.
✗ Branch 1 not taken.
27031 MsgStrings[i].copyAll(tempMsgString);
4215 27031 }
4216 }
4217
4218 129 msg_count=temp_msg_count;
4219
4220 129 return 0;
4221 129 }
4222
4223 129 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4224 {
4225
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
4226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4227 {
4228 4 return 0;
4229 }
4230
4231 125 word temp_door_combo_set_count=0;
4232 DoorComboSet tempDoorComboSet;
4233 word dummy_word;
4234 int32_t dummy_long;
4235 byte padding;
4236 125 int32_t s_version = 0;
4237
4238
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4239 {
4240 32000 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4241 32000 }
4242
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(Header->zelda_version > 0x192)
4244 {
4245 //section version info
4246
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4247 {
4248 return qe_invalid;
4249 }
4250
4251 125 FFCore.quest_format[vDoors] = s_version;
4252
4253 //al_trace("Door combo sets version %d\n", dummy_word);
4254
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy_word,f))
4255 {
4256 return qe_invalid;
4257 }
4258
4259 //section size
4260
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy_long,f))
4261 {
4262 return qe_invalid;
4263 }
4264 125 }
4265
4266 //finally... section data
4267
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_door_combo_set_count,f))
4268 {
4269 return qe_invalid;
4270 }
4271
4272
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(temp_door_combo_set_count >= 0 && temp_door_combo_set_count <= MAXDOORCOMBOSETS))
4273 {
4274 return qe_invalid;
4275 }
4276
4277
2/2
✓ Branch 0 taken 1001 times.
✓ Branch 1 taken 125 times.
1126 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4278 {
4279 1001 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4280
4281 //name
4282
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4283 {
4284 return qe_invalid;
4285 }
4286
4287
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4288 {
4289 if(!p_getc(&padding,f))
4290 {
4291 return qe_invalid;
4292 }
4293 }
4294
4295 //up door
4296
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4297 {
4298
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4299 {
4300
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4301 {
4302 return qe_invalid;
4303 }
4304 36036 }
4305 9009 }
4306
4307
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4308 {
4309
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4310 {
4311
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4312 {
4313 return qe_invalid;
4314 }
4315 36036 }
4316 9009 }
4317
4318 //down door
4319
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4320 {
4321
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4322 {
4323
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36036 times.
36036 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4324 {
4325 return qe_invalid;
4326 }
4327 36036 }
4328 9009 }
4329
4330
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4331 {
4332
2/2
✓ Branch 0 taken 36036 times.
✓ Branch 1 taken 9009 times.
45045 for(int32_t k=0; k<4; k++)
4333 {
4334
1/2
✓ Branch 0 taken 36036 times.
✗ Branch 1 not taken.
36036 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4335 {
4336 return qe_invalid;
4337 }
4338 36036 }
4339 9009 }
4340
4341 //left door
4342
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4343 {
4344
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4345 {
4346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 54054 times.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4347 {
4348 return qe_invalid;
4349 }
4350 54054 }
4351 9009 }
4352
4353
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4354 {
4355
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4356 {
4357
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4358 {
4359 return qe_invalid;
4360 }
4361 54054 }
4362 9009 }
4363
4364 //right door
4365
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4366 {
4367
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4368 {
4369
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4370 {
4371 return qe_invalid;
4372 }
4373 54054 }
4374 9009 }
4375
4376
2/2
✓ Branch 0 taken 9009 times.
✓ Branch 1 taken 1001 times.
10010 for(int32_t j=0; j<9; j++)
4377 {
4378
2/2
✓ Branch 0 taken 54054 times.
✓ Branch 1 taken 9009 times.
63063 for(int32_t k=0; k<6; k++)
4379 {
4380
1/2
✓ Branch 0 taken 54054 times.
✗ Branch 1 not taken.
54054 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4381 {
4382 return qe_invalid;
4383 }
4384 54054 }
4385 9009 }
4386
4387 //up bomb rubble
4388
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4389 {
4390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4391 {
4392 return qe_invalid;
4393 }
4394 2002 }
4395
4396
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4397 {
4398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4399 {
4400 return qe_invalid;
4401 }
4402 2002 }
4403
4404 //down bomb rubble
4405
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4406 {
4407
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4408 {
4409 return qe_invalid;
4410 }
4411 2002 }
4412
4413
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4414 {
4415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4416 {
4417 return qe_invalid;
4418 }
4419 2002 }
4420
4421 //left bomb rubble
4422
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4423 {
4424
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4425 {
4426 return qe_invalid;
4427 }
4428 3003 }
4429
4430
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4431 {
4432
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4433 {
4434 return qe_invalid;
4435 }
4436 3003 }
4437
4438
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4439 {
4440 if(!p_getc(&padding,f))
4441 {
4442 return qe_invalid;
4443 }
4444
4445 }
4446
4447 //right bomb rubble
4448
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4449 {
4450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4451 {
4452 return qe_invalid;
4453 }
4454 3003 }
4455
4456
2/2
✓ Branch 0 taken 3003 times.
✓ Branch 1 taken 1001 times.
4004 for(int32_t j=0; j<3; j++)
4457 {
4458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3003 times.
3003 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4459 {
4460 return qe_invalid;
4461 }
4462 3003 }
4463
4464
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4465 {
4466 if(!p_getc(&padding,f))
4467 {
4468 return qe_invalid;
4469 }
4470 }
4471
4472 //walkthrough stuff
4473
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4474 {
4475
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4476 {
4477 return qe_invalid;
4478 }
4479 4004 }
4480
4481
2/2
✓ Branch 0 taken 4004 times.
✓ Branch 1 taken 1001 times.
5005 for(int32_t j=0; j<4; j++)
4482 {
4483
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4004 times.
4004 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4484 {
4485 return qe_invalid;
4486 }
4487 4004 }
4488
4489 //flags
4490
2/2
✓ Branch 0 taken 2002 times.
✓ Branch 1 taken 1001 times.
3003 for(int32_t j=0; j<2; j++)
4491 {
4492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2002 times.
2002 if(!p_getc(&tempDoorComboSet.flags[j],f))
4493 {
4494 return qe_invalid;
4495 }
4496 2002 }
4497
4498
1/2
✓ Branch 0 taken 1001 times.
✗ Branch 1 not taken.
1001 if(Header->zelda_version < 0x193)
4499 {
4500 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4501 {
4502 return qe_invalid;
4503 }
4504 }
4505
4506 1001 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4507 1001 }
4508
4509 125 door_combo_set_count=temp_door_combo_set_count;
4510
4511 125 return 0;
4512 129 }
4513
4514 int32_t count_dmaps()
4515 {
4516 int32_t i=MAXDMAPS-1;
4517 bool found=false;
4518
4519 while(i>=0 && !found)
4520 {
4521 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4522 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4523 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4524 found=true;
4525
4526 for(int32_t j=0; j<8; j++)
4527 {
4528 if(DMaps[i].grid[j]!=0)
4529
4530 found=true;
4531 }
4532
4533 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4534 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4535 found=true;
4536
4537 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4538 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4539 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4540 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4541 found=true;
4542
4543 if(!found)
4544 {
4545 i--;
4546 }
4547 }
4548
4549 return i+1;
4550 }
4551
4552
4553 int32_t count_shops(miscQdata *Misc)
4554 {
4555 int32_t i=NUM_SHOPS-1,j;
4556 bool found=false;
4557
4558 while(i>=0 && !found)
4559 {
4560 j=2;
4561
4562 while(j>=0 && !found)
4563 {
4564 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4565 {
4566 found=true;
4567 }
4568 else
4569 {
4570 j--;
4571 }
4572 }
4573
4574 if(Misc->shop[i].name[0]!=0)
4575 {
4576 found=true;
4577 }
4578
4579 if(!found)
4580 {
4581 i--;
4582 }
4583 }
4584
4585 return i+1;
4586 }
4587
4588 int32_t count_infos(miscQdata *Misc)
4589 {
4590 int32_t i=255,j;
4591 bool found=false;
4592
4593 while(i>=0 && !found)
4594 {
4595 j=2;
4596
4597 while(j>=0 && !found)
4598 {
4599 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4600 {
4601 found=true;
4602 }
4603 else
4604 {
4605 j--;
4606 }
4607 }
4608
4609 if(Misc->info[i].name[0]!=0)
4610 {
4611 found=true;
4612 }
4613
4614 if(!found)
4615 {
4616 i--;
4617 }
4618 }
4619
4620 return i+1;
4621 }
4622
4623 int32_t count_warprings(miscQdata *Misc)
4624 {
4625 int32_t i=15,j;
4626 bool found=false;
4627
4628 while(i>=0 && !found)
4629 {
4630 j=7;
4631
4632 while(j>=0 && !found)
4633 {
4634 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4635 {
4636 found=true;
4637 }
4638 else
4639 {
4640 j--;
4641 }
4642 }
4643
4644 if(!found)
4645 {
4646 i--;
4647 }
4648 }
4649
4650 return i+1;
4651 }
4652
4653 int32_t count_palcycles(miscQdata *Misc)
4654 {
4655 int32_t i=255,j;
4656 bool found=false;
4657
4658 while(i>=0 && !found)
4659 {
4660 j=2;
4661
4662 while(j>=0 && !found)
4663 {
4664 if(Misc->cycles[i][j].count!=0)
4665 {
4666 found=true;
4667 }
4668 else
4669 {
4670 j--;
4671 }
4672 }
4673
4674 if(!found)
4675 {
4676 i--;
4677 }
4678 }
4679
4680 return i+1;
4681 }
4682
4683 264713 void clear_screen(mapscr *temp_scr)
4684 {
4685 264713 temp_scr->zero_memory();
4686 264713 }
4687
4688 129 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4689 {
4690 129 word dmapstoread=0;
4691 dmap tempDMap;
4692
4693 int32_t dummy;
4694 129 word s_version=0, s_cversion=0;
4695 byte padding;
4696
4697
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<max_dmaps; i++)
4698 {
4699 66048 memset(&DMaps[start_dmap+i],0,sizeof(dmap));
4700 66048 sprintf(DMaps[start_dmap+i].title," ");
4701 66048 sprintf(DMaps[start_dmap+i].intro," ");
4702 66048 DMaps[start_dmap+i].type |= dmCAVE;
4703 66048 }
4704
4705
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 4 times.
129 if(!Header || Header->zelda_version > 0x192)
4706 {
4707 //section version info
4708
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
4709 {
4710 return qe_invalid;
4711 }
4712
4713 125 FFCore.quest_format[vDMaps] = s_version;
4714
4715 //al_trace("DMaps version %d\n", s_version);
4716
4717
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
4718 {
4719 return qe_invalid;
4720 }
4721
4722 //section size
4723
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
4724 {
4725 return qe_invalid;
4726 }
4727
4728 //finally... section data
4729
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dmapstoread,f))
4730 {
4731 return qe_invalid;
4732 }
4733 125 }
4734 else
4735 {
4736
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
4737 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4738 {
4739 4 dmapstoread=32;
4740 4 }
4741 else if(s_version <= 4)
4742 {
4743 dmapstoread=OLDMAXDMAPS;
4744 }
4745 else
4746 {
4747 dmapstoread=MAXDMAPS;
4748 }
4749 }
4750
4751
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, max_dmaps);
4752
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4753
4754
2/2
✓ Branch 0 taken 61056 times.
✓ Branch 1 taken 129 times.
61185 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4755 {
4756 61056 memset(&tempDMap,0,sizeof(dmap));
4757 61056 sprintf(tempDMap.title," ");
4758 61056 sprintf(tempDMap.intro," ");
4759
4760
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.map,f))
4761 {
4762 return qe_invalid;
4763 }
4764
4765
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version <= 4)
4766 {
4767 byte tempbyte;
4768
4769
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4770 {
4771 return qe_invalid;
4772 }
4773
4774 3200 tempDMap.level=(word)tempbyte;
4775 3200 }
4776 else
4777 {
4778
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.level,f))
4779 {
4780 return qe_invalid;
4781 }
4782 }
4783
4784
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.xoff,f))
4785 {
4786 return qe_invalid;
4787 }
4788
4789
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.compass,f))
4790 {
4791 return qe_invalid;
4792 }
4793
4794
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version > 8) // February 2009
4795 {
4796
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&tempDMap.color,f))
4797 {
4798 return qe_invalid;
4799 }
4800 57856 }
4801 else
4802 {
4803 byte tempbyte;
4804
4805
1/2
✓ Branch 0 taken 3200 times.
✗ Branch 1 not taken.
3200 if(!p_getc(&tempbyte,f))
4806 {
4807 return qe_invalid;
4808 }
4809
4810 3200 tempDMap.color = (word)tempbyte;
4811 }
4812
4813
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.midi,f))
4814 {
4815 return qe_invalid;
4816 }
4817
4818
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.cont,f))
4819 {
4820 return qe_invalid;
4821 }
4822
4823
1/2
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
61056 if(!p_getc(&tempDMap.type,f))
4824 {
4825 return qe_invalid;
4826 }
4827
4828
4/4
✓ Branch 0 taken 830 times.
✓ Branch 1 taken 60226 times.
✓ Branch 2 taken 818 times.
✓ Branch 3 taken 12 times.
61886 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4829
1/2
✓ Branch 0 taken 830 times.
✗ Branch 1 not taken.
830 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4830 818 tempDMap.xoff = 0;
4831
4832
2/2
✓ Branch 0 taken 488448 times.
✓ Branch 1 taken 61056 times.
549504 for(int32_t j=0; j<8; j++)
4833 {
4834
1/2
✓ Branch 0 taken 488448 times.
✗ Branch 1 not taken.
488448 if(!p_getc(&tempDMap.grid[j],f))
4835 {
4836 return qe_invalid;
4837 }
4838 488448 }
4839
4840
4/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✓ Branch 3 taken 128 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4841 {
4842
3/4
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 38 times.
128 if(tempDMap.level>0&&tempDMap.level<10)
4843 {
4844 38 sprintf(tempDMap.title,"LEVEL-%d ", tempDMap.level);
4845 38 }
4846
4847
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 124 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
128 if(i==0 && Header->zelda_version <= 0x190)
4848 {
4849 4 tempDMap.cont-=tempDMap.xoff;
4850 4 tempDMap.compass-=tempDMap.xoff;
4851 4 }
4852
4853 //forgotten -DD
4854
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 90 times.
128 if(tempDMap.level==0)
4855 {
4856 90 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4857 90 }
4858 128 }
4859 else
4860 {
4861
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.name,sizeof(DMaps[0].name),f))
4862 {
4863 return qe_invalid;
4864 }
4865
4866
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.title,sizeof(DMaps[0].title),f))
4867 {
4868 return qe_invalid;
4869 }
4870
4871
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.intro,sizeof(DMaps[0].intro),f))
4872 {
4873 return qe_invalid;
4874 }
4875
4876
3/8
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 60928 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
60928 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4877 {
4878 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4879 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
4880
4881 continue;
4882 }
4883
4884
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4885 {
4886 if(!p_getc(&padding,f))
4887 {
4888 return qe_invalid;
4889 }
4890 }
4891
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4892 {
4893
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4894 {
4895 return qe_invalid;
4896 }
4897 18432 }
4898 else
4899 {
4900
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4901 {
4902 return qe_invalid;
4903 }
4904 }
4905
4906
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_1_cset,f))
4907 {
4908 return qe_invalid;
4909 }
4910
4911
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4912 {
4913 if(!p_getc(&padding,f))
4914 {
4915 return qe_invalid;
4916 }
4917 }
4918
4919
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4920 {
4921
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4922 {
4923 return qe_invalid;
4924 }
4925 18432 }
4926 else
4927 {
4928
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4929 {
4930 return qe_invalid;
4931 }
4932 }
4933
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.minimap_2_cset,f))
4934 {
4935 return qe_invalid;
4936 }
4937
4938
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4939 {
4940 if(!p_getc(&padding,f))
4941 {
4942 return qe_invalid;
4943 }
4944 }
4945
4946
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4947 {
4948
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4949 {
4950 return qe_invalid;
4951 }
4952 18432 }
4953 else
4954 {
4955
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4956 {
4957 return qe_invalid;
4958 }
4959 }
4960
4961
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_1_cset,f))
4962 {
4963 return qe_invalid;
4964 }
4965
4966
2/4
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60928 times.
✗ Branch 3 not taken.
60928 if(Header && (Header->zelda_version < 0x193))
4967 {
4968
4969 if(!p_getc(&padding,f))
4970 {
4971 return qe_invalid;
4972 }
4973 }
4974
4975
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42496 times.
60928 if ( s_version >= 11 )
4976 {
4977
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4978 {
4979 return qe_invalid;
4980 }
4981 18432 }
4982 else
4983 {
4984
1/2
✓ Branch 0 taken 42496 times.
✗ Branch 1 not taken.
42496 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4985 {
4986 return qe_invalid;
4987 }
4988 }
4989
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!p_getc(&tempDMap.largemap_2_cset,f))
4990 {
4991 return qe_invalid;
4992 }
4993
4994
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(&tempDMap.tmusic,sizeof(DMaps[0].tmusic),f))
4995 {
4996 return qe_invalid;
4997 }
4998 }
4999
5000
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>1)
5001 {
5002
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.tmusictrack,f))
5003 {
5004 return qe_invalid;
5005 }
5006
5007
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.active_subscreen,f))
5008 {
5009 return qe_invalid;
5010 }
5011
5012
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempDMap.passive_subscreen,f))
5013 {
5014 return qe_invalid;
5015 }
5016 57856 }
5017
5018
2/2
✓ Branch 0 taken 3200 times.
✓ Branch 1 taken 57856 times.
61056 if(s_version>2)
5019 {
5020 byte di[32];
5021
5022
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(&di, 32, f)) return qe_invalid;
5023
5024
2/2
✓ Branch 0 taken 14811136 times.
✓ Branch 1 taken 57856 times.
14868992 for(int32_t j=0; j<MAXITEMS; j++)
5025 {
5026
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 14811129 times.
14811136 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
5027 14811129 else tempDMap.disableditems[j]=0;
5028 14811136 }
5029 57856 }
5030
5031
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version >= 6)
5032 {
5033
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&tempDMap.flags,f))
5034 {
5035 return qe_invalid;
5036 }
5037 57856 }
5038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3200 times.
3200 else if(s_version>3)
5039 {
5040 char temp;
5041
5042 if(!p_getc(&temp,f))
5043 {
5044 return qe_invalid;
5045 }
5046
5047 tempDMap.flags = temp;
5048 }
5049
3/8
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 816 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
3200 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
5050 {
5051 816 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
5052 816 }
5053 else
5054 2384 tempDMap.flags=0;
5055
5056
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<7)
5057 {
5058
3/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 816 times.
✗ Branch 3 not taken.
3200 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
5059 816 tempDMap.flags|= dmfVIEWMAP;
5060 3200 }
5061
5062
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 3200 times.
61056 if(s_version<8)
5063 {
5064
4/4
✓ Branch 0 taken 816 times.
✓ Branch 1 taken 2384 times.
✓ Branch 2 taken 207 times.
✓ Branch 3 taken 609 times.
3200 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
5065 {
5066 609 tempDMap.type &= ~dmDNGN;
5067 609 tempDMap.type |= dmCAVE;
5068 609 }
5069
2/2
✓ Branch 0 taken 855 times.
✓ Branch 1 taken 1736 times.
2591 else if((tempDMap.type&dmfTYPE)==dmCAVE)
5070 {
5071 1736 tempDMap.flags |= dmfMINIMAPCOLORFIX;
5072 1736 }
5073 3200 }
5074
5075
5/8
✓ Branch 0 taken 61056 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 128 times.
✓ Branch 3 taken 60928 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 128 times.
✓ Branch 6 taken 60928 times.
✗ Branch 7 not taken.
61056 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
5076 60928 && (Header->zelda_version < 0x193))
5077 {
5078 if(!p_getc(&padding,f))
5079 {
5080 return qe_invalid;
5081 }
5082 }
5083
5084
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 10)
5085 {
5086
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempDMap.sideview,f))
5087 {
5088 return qe_invalid;
5089 }
5090 18432 }
5091
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version < 10) tempDMap.sideview = 0;
5092
5093 //Dmap Scripts
5094
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 12)
5095 {
5096
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.script,f))
5097 {
5098 return qe_invalid;
5099 }
5100
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5101 {
5102
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.initD[q],f))
5103 {
5104 return qe_invalid;
5105 }
5106 147456 }
5107 18432 }
5108
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 12 )
5109 {
5110 42624 tempDMap.script = 0;
5111
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5112 {
5113 340992 tempDMap.initD[q] = 0;
5114 340992 }
5115 42624 }
5116
5117
2/2
✓ Branch 0 taken 42624 times.
✓ Branch 1 taken 18432 times.
61056 if(s_version >= 13)
5118 {
5119
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
5120 {
5121
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
5122 {
5123
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.initD_label[q][w],f))
5124 {
5125 return qe_invalid;
5126 }
5127 9584640 }
5128 147456 }
5129 18432 }
5130
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if ( s_version < 13 )
5131 {
5132 42624 tempDMap.script = 0;
5133
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for ( int32_t q = 0; q < 8; q++ )
5134 {
5135
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for ( int32_t w = 0; w < 65; w++ )
5136 22164480 tempDMap.initD_label[q][w] = 0;
5137 340992 }
5138 42624 }
5139
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 14)
5140 {
5141
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.active_sub_script,f))
5142 {
5143 return qe_invalid;
5144 }
5145
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.passive_sub_script,f))
5146 {
5147 return qe_invalid;
5148 }
5149
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5150 {
5151
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.sub_initD[q],f))
5152 {
5153 return qe_invalid;
5154 }
5155 147456 }
5156
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5157 {
5158
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5159 {
5160
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5161 {
5162 return qe_invalid;
5163 }
5164 9584640 }
5165 147456 }
5166 18432 }
5167 else
5168 {
5169 42624 tempDMap.active_sub_script = 0;
5170 42624 tempDMap.passive_sub_script = 0;
5171
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5172 {
5173 340992 tempDMap.sub_initD[q] = 0;
5174
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5175 22164480 tempDMap.sub_initD_label[q][w] = 0;
5176 340992 }
5177 }
5178
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 15)
5179 {
5180
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&tempDMap.onmap_script,f))
5181 {
5182 return qe_invalid;
5183 }
5184
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; ++q )
5185 {
5186
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5187 {
5188 return qe_invalid;
5189 }
5190 147456 }
5191
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for(int32_t q = 0; q < 8; ++q)
5192 {
5193
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; ++w )
5194 {
5195
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5196 {
5197 return qe_invalid;
5198 }
5199 9584640 }
5200 147456 }
5201 18432 }
5202 else
5203 {
5204 42624 tempDMap.onmap_script = 0;
5205
2/2
✓ Branch 0 taken 340992 times.
✓ Branch 1 taken 42624 times.
383616 for(int32_t q = 0; q < 8; ++q)
5206 {
5207 340992 tempDMap.onmap_initD[q] = 0;
5208
2/2
✓ Branch 0 taken 22164480 times.
✓ Branch 1 taken 340992 times.
22505472 for(int32_t w = 0; w < 65; ++w)
5209 {
5210 22164480 tempDMap.onmap_initD_label[q][w] = 0;
5211 22164480 }
5212 340992 }
5213 }
5214
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 42624 times.
61056 if(s_version >= 16)
5215 {
5216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempDMap.mirrorDMap,f))
5217 {
5218 return qe_invalid;
5219 }
5220 18432 }
5221 else
5222 {
5223 42624 tempDMap.mirrorDMap = -1;
5224 }
5225
5226
2/2
✓ Branch 0 taken 51328 times.
✓ Branch 1 taken 9728 times.
61056 if(s_version >= 17)
5227 {
5228 // Reserved for z3.
5229 9728 }
5230
5231 61056 memcpy(&DMaps[i], &tempDMap, sizeof(tempDMap));
5232 61056 }
5233
5234 129 return 0;
5235 129 }
5236
5237 113 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5238 {
5239 //these are here to bypass compiler warnings about unused arguments
5240 113 Header=Header;
5241
5242 miscQdata temp_misc;
5243 113 word s_version=0, s_cversion=0;
5244 113 int32_t tempsize=0;
5245 word dummyw;
5246
5247 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5248
5249 //section version info
5250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5251 {
5252 return qe_invalid;
5253 }
5254
5255 113 FFCore.quest_format[vColours] = s_version;
5256
5257 113 al_trace("Misc Colours section version: %d\n", s_version);
5258
5259 //al_trace("Misc. colors version %d\n", s_version);
5260
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
5266 //section size
5267
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5268 {
5269 return qe_invalid;
5270 }
5271
5272 //finally... section data
5273 113 readsize=0;
5274
5275
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.text,f))
5276 {
5277 return qe_invalid;
5278 }
5279
5280
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.caption,f))
5281 {
5282 return qe_invalid;
5283 }
5284
5285
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overw_bg,f))
5286 {
5287 return qe_invalid;
5288 }
5289
5290
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5296 {
5297 return qe_invalid;
5298 }
5299
5300
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.cave_fg,f))
5301 {
5302 return qe_invalid;
5303 }
5304
5305
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_dk,f))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bs_goal,f))
5311 {
5312 return qe_invalid;
5313 }
5314
5315
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_lt,f))
5316 {
5317 return qe_invalid;
5318 }
5319
5320
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.compass_dk,f))
5321 {
5322 return qe_invalid;
5323 }
5324
5325
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5326 {
5327 return qe_invalid;
5328 }
5329
5330
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_color,f))
5331 {
5332 return qe_invalid;
5333 }
5334
5335
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.hero_dot,f))
5336 {
5337 return qe_invalid;
5338 }
5339
5340
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5341 {
5342 return qe_invalid;
5343 }
5344
5345
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5346 {
5347 return qe_invalid;
5348 }
5349
5350
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5351 {
5352 return qe_invalid;
5353 }
5354
5355
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5356 {
5357 return qe_invalid;
5358 }
5359
5360
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5361 {
5362 return qe_invalid;
5363 }
5364
5365
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5366 {
5367 return qe_invalid;
5368 }
5369
5370
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5371 {
5372 return qe_invalid;
5373 }
5374
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 4)
5375 {
5376
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5377 return qe_invalid;
5378 77 temp_misc.colors.triforce_tile = dummyw;
5379
5380
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5381 return qe_invalid;
5382 77 temp_misc.colors.triframe_tile = dummyw;
5383
5384
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5385 return qe_invalid;
5386 77 temp_misc.colors.overworld_map_tile = dummyw;
5387
5388
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5389 return qe_invalid;
5390 77 temp_misc.colors.dungeon_map_tile = dummyw;
5391
5392
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5393 return qe_invalid;
5394 77 temp_misc.colors.blueframe_tile = dummyw;
5395
5396
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&dummyw,f))
5397 return qe_invalid;
5398 77 temp_misc.colors.HCpieces_tile = dummyw;
5399 77 }
5400
5401
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5402 {
5403 return qe_invalid;
5404 }
5405
5406
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5407 {
5408 return qe_invalid;
5409 }
5410
5411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 2)
5412 {
5413 temp_misc.colors.msgtext = 0x01;
5414 }
5415 else
5416 {
5417
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_getc(&temp_misc.colors.msgtext, f))
5418 {
5419 return qe_invalid;
5420 }
5421 }
5422
5423
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if ( s_version >= 3 ) //expanded tile pages to 825
5424 {
5425
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5426 {
5427 return qe_invalid;
5428 }
5429
5430
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5431 {
5432 return qe_invalid;
5433 }
5434
5435
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5436 {
5437 return qe_invalid;
5438 }
5439
5440
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5441 {
5442 return qe_invalid;
5443 }
5444
5445
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5446 {
5447 return qe_invalid;
5448 }
5449
5450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5451 {
5452 return qe_invalid;
5453 }
5454 36 }
5455
5456 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5457
5458 113 return 0;
5459 113 }
5460
5461 113 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5462 {
5463 miscQdata temp_misc;
5464 113 word s_version=0, s_cversion=0;
5465 byte icons;
5466 113 int32_t tempsize=0;
5467
5468 113 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5469
5470 //section version info
5471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
5472 {
5473 return qe_invalid;
5474 }
5475
5476 113 FFCore.quest_format[vIcons] = s_version;
5477
5478 //al_trace("Game icons version %d\n", s_version);
5479
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
5480 {
5481 return qe_invalid;
5482 }
5483
5484
5485 //section size
5486
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&tempsize,f))
5487 {
5488 return qe_invalid;
5489 }
5490
5491 //finally... section data
5492 113 readsize=0;
5493
5494 113 icons=4;
5495
5496
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 10 )
5497 {
5498
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<icons; i++)
5499 {
5500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&temp_misc.icons[i],f))
5501 {
5502 return qe_invalid;
5503 }
5504 144 }
5505 36 }
5506 else
5507 {
5508
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<icons; i++)
5509 {
5510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 308 times.
308 if(!p_igetw(&temp_misc.icons[i],f))
5511 {
5512 return qe_invalid;
5513 }
5514 308 }
5515 }
5516
5517 113 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5518
5519 113 return 0;
5520 113 }
5521
5522 129 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5523 {
5524 129 word maxinfos=256;
5525 129 word maxshops=256;
5526 129 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5527 129 word ponds=16, pondsize=72, expansionsize=98*2;
5528 byte tempbyte, padding;
5529 miscQdata temp_misc;
5530 129 word s_version=0, s_cversion=0;
5531 word swaptmp;
5532 129 int32_t tempsize=0;
5533
5534 129 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5535
5536
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5537 {
5538 33024 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5539 33024 }
5540
5541
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5542 {
5543 33024 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5544 33024 }
5545
5546
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5547 {
5548 //section version info
5549
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
5550 {
5551 return qe_invalid;
5552 }
5553
5554 125 FFCore.quest_format[vMisc] = s_version;
5555
5556 //al_trace("Misc. data version %d\n", s_version);
5557
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
5558 {
5559 return qe_invalid;
5560 }
5561
5562
5563 //section size
5564
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&tempsize,f))
5565 {
5566 return qe_invalid;
5567 }
5568 125 }
5569
5570 //finally... section data
5571 129 readsize=0;
5572
5573 //shops
5574
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5575 {
5576
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&shops,f))
5577 {
5578 return qe_invalid;
5579 }
5580 125 }
5581
5582
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(shops >= 0 && shops <= NUM_SHOPS))
5583 {
5584 return qe_invalid;
5585 }
5586
5587
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 129 times.
1585 for(int32_t i=0; i<shops; i++)
5588 {
5589
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 6)
5590 {
5591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1233 times.
1233 if(!pfread(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name),f))
5592 {
5593 return qe_invalid;
5594 }
5595 1233 }
5596
5597
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5598 {
5599
1/2
✓ Branch 0 taken 4368 times.
✗ Branch 1 not taken.
4368 if(!p_getc(&temp_misc.shop[i].item[j],f))
5600 {
5601 return qe_invalid;
5602 }
5603
5604
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 669 times.
4368 if(s_version < 4)
5605 {
5606 669 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5607 669 }
5608 4368 }
5609
5610
2/2
✓ Branch 0 taken 1392 times.
✓ Branch 1 taken 64 times.
1456 if(Header->zelda_version < 0x193)
5611 {
5612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(!p_getc(&tempbyte,f))
5613 {
5614 return qe_invalid;
5615 }
5616 64 }
5617
5618
2/2
✓ Branch 0 taken 4368 times.
✓ Branch 1 taken 1456 times.
5824 for(int32_t j=0; j<3; j++)
5619 {
5620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4368 times.
4368 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5621 {
5622 return qe_invalid;
5623 }
5624 4368 }
5625
5626
2/2
✓ Branch 0 taken 223 times.
✓ Branch 1 taken 1233 times.
1456 if(s_version > 3)
5627 {
5628
2/2
✓ Branch 0 taken 3699 times.
✓ Branch 1 taken 1233 times.
4932 for(int32_t j=0; j<3; j++)
5629 {
5630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3699 times.
3699 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5631 return qe_invalid;
5632 3699 }
5633 1233 }
5634
5635 /*
5636 if(s_version < 8)
5637 {
5638 for(int32_t j=0; j<3; j++)
5639 {
5640 (&temp_misc.shop[i].str[j])=0; //initialise.
5641 }
5642 }
5643 */
5644 1456 }
5645
5646 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5647
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxshops; ++i)
5648 {
5649
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5650 {
5651
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 96081 times.
162129 for(int32_t k=0; k<2-j; k++)
5652 {
5653 96081 if(temp_misc.shop[i].hasitem[k]==0)
5654 {
5655 96081 swaptmp = temp_misc.shop[i].item[k];
5656 96081 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5657 96081 temp_misc.shop[i].item[k+1] = swaptmp;
5658 96081 swaptmp = temp_misc.shop[i].price[k];
5659 96081 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5660 96081 temp_misc.shop[i].price[k+1] = swaptmp;
5661 96081 swaptmp = temp_misc.shop[i].hasitem[k];
5662 96081 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5663 96081 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5664 96081 }
5665 96081 }
5666 66048 }
5667 33024 }
5668
5669 //infos
5670
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5671 {
5672
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&infos,f))
5673 {
5674 return qe_invalid;
5675 }
5676 125 }
5677
5678
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(infos >= 0 && infos <= NUM_INFOS))
5679 {
5680 return qe_invalid;
5681 }
5682
5683
5684
2/2
✓ Branch 0 taken 1767 times.
✓ Branch 1 taken 129 times.
1896 for(int32_t i=0; i<infos; i++)
5685 {
5686
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 1667 times.
1767 if(s_version > 6)
5687 {
5688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1667 times.
1667 if(!pfread(temp_misc.info[i].name,sizeof(temp_misc.info[i].name),f))
5689 {
5690 return qe_invalid;
5691 }
5692 1667 }
5693
5694
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5695 {
5696
2/4
✓ Branch 0 taken 5109 times.
✓ Branch 1 taken 192 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5301 if((Header->zelda_version < 0x192)||
5697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5698 {
5699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5700 {
5701 return qe_invalid;
5702 }
5703
5704 192 temp_misc.info[i].str[j]=tempbyte;
5705 192 }
5706 else
5707 {
5708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5109 times.
5109 if(!p_igetw(&temp_misc.info[i].str[j],f))
5709 {
5710 return qe_invalid;
5711 }
5712 }
5713 5301 }
5714
5715
2/2
✓ Branch 0 taken 1703 times.
✓ Branch 1 taken 64 times.
1767 if(Header->zelda_version < 0x193)
5716 {
5717
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbyte,f))
5718 {
5719 return qe_invalid;
5720 }
5721 64 }
5722
5723
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1767 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1767 if((Header->zelda_version == 0x192)&&(Header->build>145))
5724 {
5725 if(!p_getc(&padding,f))
5726 {
5727 return qe_invalid;
5728 }
5729 }
5730
5731
2/2
✓ Branch 0 taken 5301 times.
✓ Branch 1 taken 1767 times.
7068 for(int32_t j=0; j<3; j++)
5732 {
5733
1/2
✓ Branch 0 taken 5301 times.
✗ Branch 1 not taken.
5301 if(!p_igetw(&temp_misc.info[i].price[j],f))
5734 {
5735 return qe_invalid;
5736 }
5737 5301 }
5738 1767 }
5739
5740 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5741
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<maxinfos; ++i)
5742 {
5743
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 33024 times.
99072 for(int32_t j=0; j<3-1; j++)
5744 {
5745
2/2
✓ Branch 0 taken 99072 times.
✓ Branch 1 taken 66048 times.
165120 for(int32_t k=0; k<2-j; k++)
5746 {
5747
2/2
✓ Branch 0 taken 2094 times.
✓ Branch 1 taken 96978 times.
99072 if(temp_misc.info[i].str[k]==0)
5748 {
5749 96978 swaptmp = temp_misc.info[i].str[k];
5750 96978 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5751 96978 temp_misc.info[i].str[k+1] = swaptmp;
5752 96978 swaptmp = temp_misc.info[i].price[k];
5753 96978 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5754 96978 temp_misc.info[i].price[k+1] = swaptmp;
5755 96978 }
5756 99072 }
5757 66048 }
5758 33024 }
5759
5760
5761 //warp rings
5762
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version > 5)
5763 113 warprings++;
5764
5765
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
5766 {
5767
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&warprings,f))
5768 {
5769 return qe_invalid;
5770 }
5771
5772
3/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 87 times.
✓ Branch 3 taken 38 times.
125 if (!(warprings >= 0 && warprings <= NUM_WARP_RINGS))
5773 {
5774 // return qe_invalid;
5775 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5776 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5777 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5778 38 }
5779 125 }
5780
5781
2/2
✓ Branch 0 taken 1298 times.
✓ Branch 1 taken 129 times.
1427 for(int32_t i=0; i<warprings; i++)
5782 {
5783 // See above comment on the `warprings` range check.
5784 1298 bool keepdata = i < NUM_WARP_RINGS;
5785
5786
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5787 {
5788
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 9666 times.
11458 if(s_version <= 3)
5789 {
5790
1/2
✓ Branch 0 taken 1792 times.
✗ Branch 1 not taken.
1792 if(!p_getc(&tempbyte,f))
5791 {
5792 return qe_invalid;
5793 }
5794
5795
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 1120 times.
1792 if (keepdata)
5796 1120 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5797 1792 }
5798 else
5799 {
5800 word tempword;
5801
1/2
✓ Branch 0 taken 9666 times.
✗ Branch 1 not taken.
9666 if(!p_igetw(&tempword,f))
5802 {
5803 return qe_invalid;
5804 }
5805
5806
2/2
✓ Branch 0 taken 513 times.
✓ Branch 1 taken 9153 times.
9666 if (keepdata)
5807 9153 temp_misc.warp[i].dmap[j] = tempword;
5808 }
5809 11458 }
5810
5811
2/2
✓ Branch 0 taken 11458 times.
✓ Branch 1 taken 1298 times.
12756 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5812 {
5813
1/2
✓ Branch 0 taken 11458 times.
✗ Branch 1 not taken.
11458 if(!p_getc(&tempbyte,f))
5814 {
5815 return qe_invalid;
5816 }
5817
2/2
✓ Branch 0 taken 1185 times.
✓ Branch 1 taken 10273 times.
11458 if (keepdata)
5818 10273 temp_misc.warp[i].scr[j] = tempbyte;
5819 11458 }
5820
5821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1298 times.
1298 if(!p_getc(&tempbyte,f))
5822 {
5823 return qe_invalid;
5824 }
5825
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 1157 times.
1298 if (keepdata)
5826 1157 temp_misc.warp[i].size = tempbyte;
5827
5828
2/2
✓ Branch 0 taken 1266 times.
✓ Branch 1 taken 32 times.
1298 if(Header->zelda_version < 0x193)
5829 {
5830
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(!p_getc(&tempbyte,f))
5831 {
5832 return qe_invalid;
5833 }
5834 32 }
5835 1298 }
5836
5837 //palette cycles
5838
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5839 {
5840
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 4 times.
1028 for(int32_t i=0; i<256; i++)
5841 {
5842
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 1024 times.
4096 for(int32_t j=0; j<3; j++)
5843 {
5844 3072 temp_misc.cycles[i][j].first=0;
5845 3072 temp_misc.cycles[i][j].count=0;
5846 3072 temp_misc.cycles[i][j].speed=0;
5847 3072 }
5848 1024 }
5849
5850
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
4 if((Header->zelda_version < 0x192)||
5851 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5852 {
5853 4 palcycles=16;
5854 4 }
5855
5856
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4 times.
68 for(int32_t i=0; i<palcycles; i++)
5857 {
5858
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 64 times.
256 for(int32_t j=0; j<3; j++)
5859 {
5860
1/2
✓ Branch 0 taken 192 times.
✗ Branch 1 not taken.
192 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5861 {
5862 return qe_invalid;
5863 }
5864
5865
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5866 {
5867 return qe_invalid;
5868 }
5869
5870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5871 {
5872 return qe_invalid;
5873 }
5874 192 }
5875 64 }
5876 4 }
5877
5878 //Wind warps are now just another warp ring.
5879
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version <= 5)
5880 {
5881
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(Header->zelda_version > 0x192)
5882 {
5883
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(!p_igetw(&windwarps,f))
5884 {
5885 return qe_invalid;
5886 }
5887 12 }
5888
5889
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 16 times.
16 if (!(windwarps >= 0 && windwarps <= NUM_WARP_RINGS))
5890 {
5891 return qe_invalid;
5892 }
5893
5894
2/2
✓ Branch 0 taken 135 times.
✓ Branch 1 taken 16 times.
151 for(int32_t i=0; i<windwarps; i++)
5895 {
5896
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version <= 3)
5897 {
5898
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&tempbyte,f))
5899 {
5900 return qe_invalid;
5901 }
5902
5903 135 temp_misc.warp[8].dmap[i]=tempbyte;
5904 135 }
5905 else
5906 {
5907 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5908 {
5909 return qe_invalid;
5910 }
5911 }
5912
5913
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5914 {
5915 return qe_invalid;
5916 }
5917
5918 135 temp_misc.warp[8].size = 9;
5919
5920
1/2
✓ Branch 0 taken 135 times.
✗ Branch 1 not taken.
135 if(s_version == 5)
5921 {
5922 if(!p_getc(&tempbyte,f))
5923 {
5924 return qe_invalid;
5925 }
5926 }
5927 135 }
5928 16 }
5929
5930
5931 //triforce pieces
5932
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<triforces; i++)
5933 {
5934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1032 times.
1032 if(!p_getc(&temp_misc.triforce[i],f))
5935 {
5936 return qe_invalid;
5937 }
5938 1032 }
5939
5940 //misc color data
5941
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<3)
5942 {
5943
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.text,f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.caption,f))
5949 {
5950 return qe_invalid;
5951 }
5952
5953
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overw_bg,f))
5954 {
5955 return qe_invalid;
5956 }
5957
5958
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5959 {
5960 return qe_invalid;
5961 }
5962
5963
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5964 {
5965 return qe_invalid;
5966 }
5967
5968
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.cave_fg,f))
5969 {
5970 return qe_invalid;
5971 }
5972
5973
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_dk,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bs_goal,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_lt,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.compass_dk,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_color,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.hero_dot,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_bg,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.bmap_fg,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triforce_cset,f))
6019 {
6020 return qe_invalid;
6021 }
6022
6023
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.triframe_cset,f))
6024 {
6025 return qe_invalid;
6026 }
6027
6028
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
6029 {
6030 return qe_invalid;
6031 }
6032
6033
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
6034 {
6035 return qe_invalid;
6036 }
6037
6038
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
6039 {
6040 return qe_invalid;
6041 }
6042
6043
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
6044 {
6045 return qe_invalid;
6046 }
6047
6048
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
6049 {
6050 return qe_invalid;
6051 }
6052
6053
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
6054 {
6055 return qe_invalid;
6056 }
6057
6058
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
6059 {
6060 return qe_invalid;
6061 }
6062
6063
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6064 {
6065 return qe_invalid;
6066 }
6067
6068
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6069 {
6070 return qe_invalid;
6071 }
6072
6073
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6074 {
6075 return qe_invalid;
6076 }
6077
6078 16 temp_misc.colors.msgtext = 0x01;
6079
6080
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(Header->zelda_version < 0x193)
6081 {
6082
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 4 times.
32 for(int32_t i=0; i<7; i++)
6083 {
6084
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(!p_getc(&tempbyte,f))
6085 {
6086 return qe_invalid;
6087 }
6088 28 }
6089 4 }
6090
6091
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version == 0x192)&&(Header->build>145))
6092 {
6093 for(int32_t i=0; i<256; i++)
6094 {
6095 if(!p_getc(&tempbyte,f))
6096 {
6097 return qe_invalid;
6098 }
6099 }
6100 }
6101
6102
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(s_version>1)
6103 {
6104 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6105 {
6106 return qe_invalid;
6107 }
6108 }
6109
6110 //save game icons
6111
2/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16 if((Header->zelda_version < 0x192)||
6112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6113 {
6114 4 icons=3;
6115 4 }
6116
6117
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 16 times.
76 for(int32_t i=0; i<icons; i++)
6118 {
6119
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_igetw(&temp_misc.icons[i],f))
6120 {
6121 return qe_invalid;
6122 }
6123 60 }
6124 16 }
6125
6126
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
6127
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6128 {
6129 4 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6130
6131 4 return 0;
6132 }
6133
6134 //pond information
6135
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6136 {
6137 if((Header->zelda_version == 0x192)&&(Header->build<146))
6138 {
6139 pondsize=25;
6140 }
6141
6142 for(int32_t i=0; i<ponds; i++)
6143 {
6144 for(int32_t j=0; j<pondsize; j++)
6145 {
6146 if(!p_getc(&tempbyte,f))
6147 {
6148 return qe_invalid;
6149
6150 }
6151 }
6152 }
6153 }
6154
6155 //end string
6156
1/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version < 0x192)||
6157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6158 {
6159 if(!p_getc(&tempbyte,f))
6160 {
6161 return qe_invalid;
6162 }
6163
6164 temp_misc.endstring=tempbyte;
6165
6166 if(!p_getc(&tempbyte,f))
6167 {
6168 return qe_invalid;
6169 }
6170 }
6171 else
6172 {
6173
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_misc.endstring,f))
6174 {
6175 return qe_invalid;
6176 }
6177 }
6178
6179 //expansion
6180
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
6181 {
6182 if((Header->zelda_version == 0x192)&&(Header->build<73))
6183 {
6184 expansionsize=99*2;
6185 }
6186
6187 for(int32_t i=0; i<expansionsize; i++)
6188 {
6189 if(!p_getc(&tempbyte,f))
6190 {
6191 return qe_invalid;
6192 }
6193 }
6194 }
6195 //shops v8
6196
6197
6198
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 8)
6199 {
6200
2/2
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 36 times.
564 for(int32_t i=0; i<shops; i++)
6201 {
6202
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 528 times.
2112 for(int32_t j=0; j<3; j++)
6203 {
6204
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6205 return qe_invalid;
6206 1584 }
6207 528 }
6208 36 }
6209
6210 125 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6211 125 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6212 125 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6213
6214 //v9 includes quest misc[32]
6215
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version >= 9)
6216 {
6217
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6218 {
6219
1/2
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
1152 if(!p_igetl(&temp_misc.questmisc[q],f))
6220 return qe_invalid;
6221 1152 }
6222
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 36 times.
1188 for ( int32_t q = 0; q < 32; q++ )
6223 {
6224
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 1152 times.
148608 for ( int32_t j = 0; j < 128; j++ )
6225
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6226 return qe_invalid;
6227 1152 }
6228 36 }
6229
6230
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 11 )
6231 {
6232
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6233 return qe_invalid;
6234 36 }
6235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89 times.
89 else if(s_version < 11 )
6236 {
6237 89 temp_misc.zscript_last_compiled_version = -1;
6238 89 }
6239
6240 125 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6241
6242
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 12)
6243 {
6244 byte spr;
6245
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sprMAX; ++q)
6246 {
6247
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&spr,f))
6248 return qe_invalid;
6249 9216 temp_misc.sprites[q] = spr;
6250 9216 }
6251 36 }
6252 else
6253 {
6254 89 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6255 //temp_misc.sprites[sprFALL] = ;
6256 }
6257
6258
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 13)
6259 {
6260
2/2
✓ Branch 0 taken 2304 times.
✓ Branch 1 taken 36 times.
2340 for(size_t q = 0; q < 64; ++q)
6261 {
6262 2304 bottletype* bt = &(temp_misc.bottle_types[q]);
6263
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!pfread(bt->name, 32, f))
6264 return qe_invalid;
6265
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 2304 times.
9216 for(size_t j = 0; j < 3; ++j)
6266 {
6267
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_getc(&(bt->counter[j]), f))
6268 return qe_invalid;
6269
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if (!p_igetw(&(bt->amount[j]), f))
6270 return qe_invalid;
6271 6912 }
6272
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->flags), f))
6273 return qe_invalid;
6274
1/2
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
2304 if (!p_getc(&(bt->next_type), f))
6275 return qe_invalid;
6276 2304 }
6277
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(size_t q = 0; q < 256; ++q)
6278 {
6279 9216 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6280
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (!pfread(bst->name, 32, f))
6281 return qe_invalid;
6282
2/2
✓ Branch 0 taken 27648 times.
✓ Branch 1 taken 9216 times.
36864 for(size_t j = 0; j < 3; ++j)
6283 {
6284
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->fill[j]), f))
6285 return qe_invalid;
6286
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->comb[j]), f))
6287 return qe_invalid;
6288
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_getc(&(bst->cset[j]), f))
6289 return qe_invalid;
6290
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->price[j]), f))
6291 return qe_invalid;
6292
1/2
✓ Branch 0 taken 27648 times.
✗ Branch 1 not taken.
27648 if (!p_igetw(&(bst->str[j]), f))
6293 return qe_invalid;
6294 27648 }
6295 9216 }
6296 36 }
6297 else
6298 {
6299
2/2
✓ Branch 0 taken 5696 times.
✓ Branch 1 taken 89 times.
5785 for(size_t q = 0; q < 64; ++q)
6300 5696 temp_misc.bottle_types[q].clear();
6301
2/2
✓ Branch 0 taken 22784 times.
✓ Branch 1 taken 89 times.
22873 for(size_t q = 0; q < 256; ++q)
6302 22784 temp_misc.bottle_shop_types[q].clear();
6303 }
6304
6305
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version >= 14)
6306 {
6307 byte msfx;
6308
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t q = 0; q < sfxMAX; ++q)
6309 {
6310
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&msfx,f))
6311 return qe_invalid;
6312 9216 temp_misc.miscsfx[q] = msfx;
6313 9216 }
6314 36 }
6315 else
6316 {
6317 89 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6318 89 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6319 89 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6320 }
6321
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if(s_version < 15)
6322 {
6323 89 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6324 89 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6325 89 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6326 89 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6327 89 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6328 89 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6329 89 }
6330
6331 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6332
6333 125 return 0;
6334 129 }
6335
6336 extern char *item_string[MAXITEMS];
6337 extern const char *old_item_string[iLast];
6338 extern char *weapon_string[MAXWPNS];
6339 extern const char *old_weapon_string[wLast];
6340
6341 129 int32_t readitems(PACKFILE *f, word version, word build)
6342 {
6343 byte padding;
6344 int32_t dummy;
6345 129 word items_to_read=MAXITEMS;
6346 itemdata tempitem;
6347 129 word s_version=0, s_cversion=0;
6348 word dummy_word;
6349
6350
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(version < 0x186)
6351 {
6352 items_to_read=64;
6353 }
6354
6355
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
6356 {
6357 125 items_to_read=0;
6358
6359 //section version info
6360
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
6361 {
6362 return qe_invalid;
6363 }
6364
6365 125 FFCore.quest_format[vItems] = s_version;
6366
6367 //al_trace("Items version %d\n", s_version);
6368
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
6369 {
6370 return qe_invalid;
6371 }
6372
6373 //section size
6374
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
6375 {
6376 return qe_invalid;
6377 }
6378
6379 //finally... section data
6380
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&items_to_read,f))
6381 {
6382 return qe_invalid;
6383 }
6384
6385
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(items_to_read >= 0 && items_to_read <= MAXITEMS))
6386 {
6387 return qe_invalid;
6388 }
6389 125 }
6390
6391
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>1)
6392 {
6393
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<items_to_read; i++)
6394 {
6395 char tempname[64];
6396
6397
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
6398 {
6399 return qe_invalid;
6400 }
6401
6402 28928 item_string[i][0] = '\0';
6403 28928 strncat(item_string[i], tempname, 64 - 1);
6404 28928 }
6405 113 }
6406 else
6407 {
6408
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
6409 {
6410 4096 reset_itemname(i);
6411 4096 }
6412 }
6413
6414
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
6415 {
6416 33024 itemdata& id = itemsbuf[i];
6417 33024 memset(&id, 0, sizeof(itemdata));
6418 33024 id.count=-1;
6419 33024 id.playsound=WAV_SCALE;
6420 33024 reset_itembuf(&id,i);
6421 33024 }
6422
6423
2/2
✓ Branch 0 taken 30792 times.
✓ Branch 1 taken 129 times.
30921 for(int32_t i=0; i<items_to_read; i++)
6424 {
6425 30792 memset(&tempitem, 0, sizeof(itemdata));
6426 30792 reset_itembuf(&tempitem,i);
6427
6428
6429
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21576 times.
30792 if ( s_version > 35 ) //expanded tiles
6430 {
6431
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tile,f))
6432 {
6433 return qe_invalid;
6434 }
6435 9216 }
6436 else
6437 {
6438
1/2
✓ Branch 0 taken 21576 times.
✗ Branch 1 not taken.
21576 if(!p_igetw(&tempitem.tile,f))
6439 {
6440 return qe_invalid;
6441 }
6442 }
6443
6444
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.misc_flags,f))
6445 {
6446 return qe_invalid;
6447 }
6448
6449
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.csets,f))
6450 {
6451 return qe_invalid;
6452 }
6453
6454
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.frames,f))
6455 {
6456 return qe_invalid;
6457 }
6458
6459
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.speed,f))
6460 {
6461 return qe_invalid;
6462 }
6463
6464
1/2
✓ Branch 0 taken 30792 times.
✗ Branch 1 not taken.
30792 if(!p_getc(&tempitem.delay,f))
6465 {
6466 return qe_invalid;
6467 }
6468
6469
2/2
✓ Branch 0 taken 29768 times.
✓ Branch 1 taken 1024 times.
30792 if(version < 0x193)
6470 {
6471
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
6472 {
6473 return qe_invalid;
6474 }
6475
6476
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1024 if((version < 0x192)||((version == 0x192)&&(build<186)))
6477 {
6478
3/3
✓ Branch 0 taken 1016 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 4 times.
1024 switch(i)
6479 {
6480 case iShield:
6481 4 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6482 4 break;
6483
6484 case iMShield:
6485 4 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6486 4 break;
6487
6488 default:
6489 1016 tempitem.ltm=0;
6490 1016 break;
6491 }
6492
6493 1024 tempitem.count=-1;
6494 1024 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6495 1024 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6496 1024 tempitem.family=0xFF;
6497 1024 tempitem.playsound=WAV_SCALE;
6498 1024 reset_itembuf(&tempitem,i);
6499
6500 1024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6501
6502 1024 continue;
6503 }
6504 }
6505
6506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29768 times.
29768 if(!p_igetl(&tempitem.ltm,f))
6507 {
6508 return qe_invalid;
6509 }
6510
6511
1/2
✓ Branch 0 taken 29768 times.
✗ Branch 1 not taken.
29768 if(version < 0x193)
6512 {
6513 for(int32_t q=0; q<12; q++)
6514 {
6515 if(!p_getc(&padding,f))
6516 {
6517 return qe_invalid;
6518 }
6519 }
6520 }
6521
6522
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 840 times.
29768 if(s_version>1)
6523 {
6524
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if ( s_version >= 31 )
6525 {
6526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.family,f))
6527 {
6528 return qe_invalid;
6529 }
6530 9216 }
6531 else
6532 {
6533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.family,f))
6534 {
6535 return qe_invalid;
6536 }
6537 }
6538
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version < 16)
6539 if(tempitem.family == 0xFF)
6540 tempitem.family = itype_misc;
6541
6542
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.fam_type,f))
6543 {
6544 return qe_invalid;
6545 }
6546
6547
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6548 {
6549
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version>=31)
6550 {
6551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.power,f))
6552 {
6553 return qe_invalid;
6554 }
6555 9216 }
6556 else
6557 {
6558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19712 times.
19712 if(!p_getc(&tempitem.power,f))
6559 {
6560 return qe_invalid;
6561 }
6562 }
6563
6564 //converted flags from 16b to 32b -Z
6565
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version < 41 )
6566 {
6567
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_igetw(&tempitem.flags,f))
6568 {
6569 return qe_invalid;
6570 }
6571 19712 }
6572 else
6573 {
6574
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.flags,f))
6575 {
6576 return qe_invalid;
6577 }
6578 }
6579 28928 }
6580 else
6581 {
6582 //tempitem.power = tempitem.fam_type;
6583 char tempchar;
6584
6585 if(!p_getc(&tempchar,f))
6586 {
6587 return qe_invalid;
6588 }
6589
6590 tempitem.flags |= (tempchar ? ITEM_GAMEDATA : 0);
6591 }
6592
6593
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.script,f))
6594 {
6595 return qe_invalid;
6596 }
6597
6598
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6599 {
6600 if(tempitem.script > NUMSCRIPTITEM)
6601 {
6602 tempitem.script = 0;
6603 }
6604 }
6605
6606
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.count,f))
6607 {
6608 return qe_invalid;
6609 }
6610
6611
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetw(&tempitem.amount,f))
6612 {
6613 return qe_invalid;
6614 }
6615
6616
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.collect_script,f))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<=3)
6622 {
6623 if(tempitem.collect_script > NUMSCRIPTITEM)
6624 {
6625 tempitem.collect_script = 0;
6626 }
6627 }
6628
6629
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.setmax,f))
6630 {
6631 return qe_invalid;
6632 }
6633
6634
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetw(&tempitem.max,f))
6635 {
6636 return qe_invalid;
6637 }
6638
6639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.playsound,f))
6640 {
6641 return qe_invalid;
6642 }
6643
6644
2/2
✓ Branch 0 taken 231424 times.
✓ Branch 1 taken 28928 times.
260352 for(int32_t j=0; j<8; j++)
6645 {
6646
1/2
✓ Branch 0 taken 231424 times.
✗ Branch 1 not taken.
231424 if(!p_igetl(&tempitem.initiald[j],f))
6647 {
6648 return qe_invalid;
6649 }
6650 231424 }
6651
6652
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 28928 times.
86784 for(int32_t j=0; j<2; j++)
6653 {
6654
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&tempitem.initiala[j],f))
6655 {
6656 return qe_invalid;
6657 }
6658 57856 }
6659
6660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>4)
6661 {
6662
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version>5)
6663 {
6664
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn,f))
6665 {
6666 return qe_invalid;
6667 }
6668
6669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn2,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn3,f))
6675 {
6676 return qe_invalid;
6677 }
6678
6679
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn4,f))
6680 {
6681 return qe_invalid;
6682 }
6683
6684
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=15)
6685 {
6686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn5,f))
6687 {
6688 return qe_invalid;
6689 }
6690
6691
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn6,f))
6692 {
6693 return qe_invalid;
6694 }
6695
6696
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn7,f))
6697 {
6698 return qe_invalid;
6699 }
6700
6701
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn8,f))
6702 {
6703 return qe_invalid;
6704 }
6705
6706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_getc(&tempitem.wpn9,f))
6707 {
6708 return qe_invalid;
6709 }
6710
6711
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.wpn10,f))
6712 {
6713 return qe_invalid;
6714 }
6715 28928 }
6716
6717
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.pickup_hearts,f))
6718 {
6719 return qe_invalid;
6720 }
6721
6722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6723 {
6724 if(!p_igetw(&dummy_word,f))
6725 {
6726 return qe_invalid;
6727 }
6728
6729 tempitem.misc1=dummy_word;
6730
6731 if(!p_igetw(&dummy_word,f))
6732 {
6733 return qe_invalid;
6734 }
6735
6736 tempitem.misc2=dummy_word;
6737 }
6738 else
6739 {
6740
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc1,f))
6741 {
6742 return qe_invalid;
6743 }
6744
6745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc2,f))
6746 {
6747 return qe_invalid;
6748 }
6749
6750 // Version 24: shICE -> shSCRIPT; previously, all shields could block script weapons
6751
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(s_version<24)
6752 {
6753 if(tempitem.family==itype_shield)
6754 {
6755 tempitem.misc1|=shSCRIPT;
6756 }
6757 }
6758 }
6759
6760
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if(s_version < 53)
6761 {
6762 byte tempbyte;
6763
1/2
✓ Branch 0 taken 19712 times.
✗ Branch 1 not taken.
19712 if(!p_getc(&tempbyte,f))
6764 {
6765 return qe_invalid;
6766 }
6767 19712 tempitem.cost_amount[0] = tempbyte;
6768 19712 }
6769 else
6770 {
6771
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
6772 {
6773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetw(&tempitem.cost_amount[q],f))
6774 {
6775 return qe_invalid;
6776 }
6777 18432 }
6778 }
6779 28928 }
6780 else
6781 {
6782 char tempchar;
6783
6784 if(!p_getc(&tempchar,f))
6785 {
6786 return qe_invalid;
6787 }
6788
6789 tempitem.flags |= (tempchar ? ITEM_EDIBLE : 0);
6790 }
6791
6792 // June 2007: more misc. attributes
6793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version>=12)
6794 {
6795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(s_version<15)
6796 {
6797 if(!p_igetw(&dummy_word,f))
6798 {
6799 return qe_invalid;
6800 }
6801
6802 tempitem.misc3=dummy_word;
6803
6804 if(!p_igetw(&dummy_word,f))
6805 {
6806 return qe_invalid;
6807 }
6808
6809 tempitem.misc4=dummy_word;
6810 }
6811 else
6812 {
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc3,f))
6814 {
6815 return qe_invalid;
6816 }
6817
6818
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc4,f))
6819 {
6820 return qe_invalid;
6821 }
6822
6823
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc5,f))
6824 {
6825 return qe_invalid;
6826 }
6827
6828
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc6,f))
6829 {
6830 return qe_invalid;
6831 }
6832
6833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc7,f))
6834 {
6835 return qe_invalid;
6836 }
6837
6838
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc8,f))
6839 {
6840 return qe_invalid;
6841 }
6842
6843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28928 times.
28928 if(!p_igetl(&tempitem.misc9,f))
6844 {
6845 return qe_invalid;
6846 }
6847
6848
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_igetl(&tempitem.misc10,f))
6849 {
6850 return qe_invalid;
6851 }
6852 }
6853
6854
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!p_getc(&tempitem.usesound,f))
6855 {
6856 return qe_invalid;
6857 }
6858
6859
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 19712 times.
28928 if(s_version >= 49)
6860 {
6861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usesound2,f))
6862 {
6863 return qe_invalid;
6864 }
6865 9216 }
6866 19712 else tempitem.usesound2 = 0;
6867
6868
3/4
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
✓ Branch 2 taken 19712 times.
✗ Branch 3 not taken.
28928 if(s_version < 50 && tempitem.family == itype_mirror)
6869 {
6870 //Split continue/dmap warp effect/sfx, port for old
6871 tempitem.misc2 = tempitem.misc1;
6872 tempitem.usesound2 = tempitem.usesound;
6873 }
6874 28928 }
6875 28928 }
6876
6877
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6878 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.useweapon,f))
6880 {
6881 return qe_invalid;
6882 }
6883
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.usedefence,f))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weaprange,f))
6888 {
6889 return qe_invalid;
6890 }
6891
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weapduration,f))
6892 {
6893 return qe_invalid;
6894 }
6895
2/2
✓ Branch 0 taken 92160 times.
✓ Branch 1 taken 9216 times.
101376 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6896 {
6897
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92160 times.
92160 if(!p_igetl(&tempitem.weap_pattern[q],f))
6898 {
6899 return qe_invalid;
6900 }
6901 92160 }
6902 9216 }
6903
6904
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6905 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6906
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.duplicates,f))
6907 {
6908 return qe_invalid;
6909 }
6910
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < INITIAL_D; q++ )
6911 {
6912
1/2
✓ Branch 0 taken 73728 times.
✗ Branch 1 not taken.
73728 if(!p_igetl(&tempitem.weap_initiald[q],f))
6913 {
6914 return qe_invalid;
6915 }
6916 73728 }
6917
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < INITIAL_A; q++ )
6918 {
6919
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.weap_initiala[q],f))
6920 {
6921 return qe_invalid;
6922 }
6923 18432 }
6924
6925
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_getc(&tempitem.drawlayer,f))
6926 {
6927 return qe_invalid;
6928 }
6929
6930
6931
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxofs,f))
6932 {
6933 return qe_invalid;
6934 }
6935
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hyofs,f))
6936 {
6937 return qe_invalid;
6938 }
6939
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hxsz,f))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.hysz,f))
6944 {
6945 return qe_invalid;
6946 }
6947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.hzsz,f))
6948 {
6949 return qe_invalid;
6950 }
6951
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.xofs,f))
6952 {
6953 return qe_invalid;
6954 }
6955
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.yofs,f))
6956 {
6957 return qe_invalid;
6958 }
6959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxofs,f))
6960 {
6961 return qe_invalid;
6962 }
6963
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_hyofs,f))
6964 {
6965 return qe_invalid;
6966 }
6967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hxsz,f))
6968 {
6969 return qe_invalid;
6970 }
6971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hysz,f))
6972 {
6973 return qe_invalid;
6974 }
6975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_hzsz,f))
6976 {
6977 return qe_invalid;
6978 }
6979
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weap_xofs,f))
6980 {
6981 return qe_invalid;
6982 }
6983
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_yofs,f))
6984 {
6985 return qe_invalid;
6986 }
6987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.weaponscript,f))
6988 {
6989 return qe_invalid;
6990 }
6991
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.wpnsprite,f))
6992 {
6993 return qe_invalid;
6994 }
6995 9216 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6996
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < num_cost_tmr; ++q)
6997 {
6998
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6999 {
7000 return qe_invalid;
7001 }
7002 18432 }
7003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 for(auto q = num_cost_tmr; q < 2; ++q)
7004 tempitem.magiccosttimer[q] = 0;
7005 9216 }
7006
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
7007 {
7008 //Item Size FLags, TileWidth, TileHeight
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.overrideFLAGS,f))
7010 {
7011 return qe_invalid;
7012 }
7013
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tilew,f))
7014 {
7015 return qe_invalid;
7016 }
7017
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.tileh,f))
7018 {
7019 return qe_invalid;
7020 }
7021 9216 }
7022
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 29 ) //! More new vars.
7023 {
7024 //Item Size FLags, TileWidth, TileHeight
7025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
7026 {
7027 return qe_invalid;
7028 }
7029
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tilew,f))
7030 {
7031 return qe_invalid;
7032 }
7033
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.weap_tileh,f))
7034 {
7035 return qe_invalid;
7036 }
7037 9216 }
7038
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 30 ) //! More new vars.
7039 {
7040 //Pickup Type
7041
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempitem.pickup,f))
7042 {
7043 return qe_invalid;
7044 }
7045 9216 }
7046
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 32 ) //! More new vars.
7047 {
7048 //Pickup Type
7049
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.pstring,f))
7050 {
7051 return qe_invalid;
7052 }
7053 9216 }
7054
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 33 ) //! More new vars.
7055 {
7056 //Pickup Type
7057
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(!p_igetw(&tempitem.pickup_string_flags,f))
7058 {
7059 return qe_invalid;
7060 }
7061 9216 }
7062
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 34 ) //! cost counter
7063 {
7064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9216 times.
9216 if(s_version < 53)
7065 {
7066 if(!p_getc(&tempitem.cost_counter[0],f))
7067 {
7068 return qe_invalid;
7069 }
7070 }
7071 else
7072 {
7073
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for(auto q = 0; q < 2; ++q)
7074 {
7075
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&tempitem.cost_counter[q],f))
7076 {
7077 return qe_invalid;
7078 }
7079 18432 }
7080 }
7081 9216 }
7082
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 44 ) //! sprite scripts
7083 {
7084
2/2
✓ Branch 0 taken 73728 times.
✓ Branch 1 taken 9216 times.
82944 for ( int32_t q = 0; q < 8; q++ )
7085 {
7086
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7087 {
7088
1/2
✓ Branch 0 taken 4792320 times.
✗ Branch 1 not taken.
4792320 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7089 {
7090 return qe_invalid;
7091 }
7092 4792320 }
7093
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7094 {
7095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7096 {
7097 return qe_invalid;
7098 }
7099 4792320 }
7100
2/2
✓ Branch 0 taken 4792320 times.
✓ Branch 1 taken 73728 times.
4866048 for ( int32_t w = 0; w < 65; w++ )
7101 {
7102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4792320 times.
4792320 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7103 {
7104 return qe_invalid;
7105 }
7106 4792320 }
7107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 73728 times.
73728 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7108 {
7109 return qe_invalid;
7110 }
7111
7112 73728 }
7113
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 9216 times.
27648 for ( int32_t q = 0; q < 2; q++ )
7114 {
7115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18432 times.
18432 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7116 {
7117 return qe_invalid;
7118 }
7119 18432 }
7120 //Pickup Type
7121
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempitem.sprite_script,f))
7122 {
7123 return qe_invalid;
7124 }
7125 9216 }
7126
2/2
✓ Branch 0 taken 19712 times.
✓ Branch 1 taken 9216 times.
28928 if ( s_version >= 48 ) //! pickup flags
7127 {
7128
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_getc(&(tempitem.pickupflag),f))
7129 {
7130 return qe_invalid;
7131 }
7132 9216 }
7133
2/2
✓ Branch 0 taken 21248 times.
✓ Branch 1 taken 7680 times.
28928 if ( s_version >= 57 )
7134 {
7135 7680 std::string str;
7136
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 7680 times.
✓ Branch 2 taken 7680 times.
✗ Branch 3 not taken.
7680 if(!p_getcstr(&str,f))
7137 return qe_invalid;
7138 7680 strncpy(tempitem.display_name,str.c_str(),255);
7139
1/3
✓ Branch 0 taken 7680 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
7680 }
7140 28928 }
7141 else
7142 {
7143 840 tempitem.count=-1;
7144 840 tempitem.family=itype_misc;
7145 840 tempitem.flags=tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7146 840 tempitem.playsound=WAV_SCALE;
7147 840 reset_itembuf(&tempitem,i);
7148 }
7149
7150 29768 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7151 29768 }
7152
7153 //////////////////////////////////////////////////////
7154 // Now do any updates because of new item additions
7155 // (These can't be done above because items_to_read
7156 // might be too low.)
7157 //////////////////////////////////////////////////////
7158
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMS; i++)
7159 {
7160 33024 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7161
7162 //Account for older quests that didn't have an actual item for the used letter
7163
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 2 && i==iLetterUsed)
7164 {
7165 16 reset_itembuf(&tempitem, iLetterUsed);
7166 16 strcpy(item_string[i],old_item_string[i]);
7167 16 tempitem.tile = itemsbuf[iLetter].tile;
7168 16 tempitem.csets = itemsbuf[iLetter].csets;
7169 16 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7170 16 tempitem.frames = itemsbuf[iLetter].frames;
7171 16 tempitem.speed = itemsbuf[iLetter].speed;
7172 16 tempitem.ltm = itemsbuf[iLetter].ltm;
7173 16 }
7174
7175
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 3)
7176 {
7177
3/3
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 3728 times.
✓ Branch 2 taken 16 times.
4096 switch(i)
7178 {
7179 case iRocsFeather:
7180 case iHoverBoots:
7181 case iSpinScroll:
7182 case iL2SpinScroll:
7183 case iCrossScroll:
7184 case iQuakeScroll:
7185 case iL2QuakeScroll:
7186 case iWhispRing:
7187 case iL2WhispRing:
7188 case iChargeRing:
7189 case iL2ChargeRing:
7190 case iPerilScroll:
7191 case iWalletL3:
7192 case iQuiverL4:
7193 case iBombBagL4:
7194 case iBracelet:
7195 case iL2Bracelet:
7196 case iOldGlove:
7197 case iL2Ladder:
7198 case iWealthMedal:
7199 case iL2WealthMedal:
7200 case iL3WealthMedal:
7201 352 reset_itembuf(&tempitem, i);
7202 352 strcpy(item_string[i],old_item_string[i]);
7203 352 break;
7204
7205 case iSShield:
7206 16 reset_itembuf(&tempitem, i);
7207 16 strcpy(item_string[i],old_item_string[i]);
7208 16 strcpy(item_string[iShield],old_item_string[iShield]);
7209 16 strcpy(item_string[iMShield],old_item_string[iMShield]);
7210 16 break;
7211 }
7212 4096 }
7213
7214
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 5)
7215 {
7216
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 3984 times.
4096 switch(i)
7217 {
7218 case iHeartRing:
7219 case iL2HeartRing:
7220 case iL3HeartRing:
7221 case iMagicRing:
7222 case iL2MagicRing:
7223 case iL3MagicRing:
7224 case iL4MagicRing:
7225 112 reset_itembuf(&tempitem, i);
7226 112 strcpy(item_string[i],old_item_string[i]);
7227 112 break;
7228 }
7229 4096 }
7230
7231
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7232 {
7233
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(i!=iBPotion && i!=iRPotion)
7234 4064 tempitem.flags |= get_bit(deprecated_rules,32) ? ITEM_KEEPOLD : 0;
7235
7236
43/43
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 16 times.
✓ Branch 15 taken 16 times.
✓ Branch 16 taken 16 times.
✓ Branch 17 taken 16 times.
✓ Branch 18 taken 16 times.
✓ Branch 19 taken 16 times.
✓ Branch 20 taken 16 times.
✓ Branch 21 taken 16 times.
✓ Branch 22 taken 64 times.
✓ Branch 23 taken 3376 times.
✓ Branch 24 taken 16 times.
✓ Branch 25 taken 16 times.
✓ Branch 26 taken 16 times.
✓ Branch 27 taken 16 times.
✓ Branch 28 taken 16 times.
✓ Branch 29 taken 16 times.
✓ Branch 30 taken 16 times.
✓ Branch 31 taken 16 times.
✓ Branch 32 taken 16 times.
✓ Branch 33 taken 16 times.
✓ Branch 34 taken 16 times.
✓ Branch 35 taken 16 times.
✓ Branch 36 taken 16 times.
✓ Branch 37 taken 16 times.
✓ Branch 38 taken 16 times.
✓ Branch 39 taken 16 times.
✓ Branch 40 taken 16 times.
✓ Branch 41 taken 16 times.
✓ Branch 42 taken 16 times.
4096 switch(i)
7237 {
7238 case iTriforce:
7239 16 tempitem.fam_type=1;
7240 16 break;
7241
7242 case iBigTri:
7243 16 tempitem.fam_type=0;
7244 16 break;
7245
7246 case iBombs:
7247 16 tempitem.fam_type=i_bomb;
7248 16 tempitem.power=4;
7249 16 tempitem.wpn=wBOMB;
7250 16 tempitem.wpn2=wBOOM;
7251 16 tempitem.misc1 = 50;
7252
7253
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7254
7255 16 break;
7256
7257 case iSBomb:
7258 16 tempitem.fam_type=i_sbomb;
7259 16 tempitem.power=16;
7260 16 tempitem.wpn=wSBOMB;
7261 16 tempitem.wpn2=wSBOOM;
7262 16 tempitem.misc1 = 50;
7263
7264
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7265
7266 16 break;
7267
7268 case iBook:
7269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7270 tempitem.wpn = wFIREMAGIC;
7271
7272 16 break;
7273
7274 case iSArrow:
7275 16 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7276 16 tempitem.power=4;
7277 16 tempitem.flags|=ITEM_GAMEDATA;
7278 16 tempitem.wpn=wSARROW;
7279 16 break;
7280
7281 case iGArrow:
7282 16 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7283 16 tempitem.power=8;
7284 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7285 16 tempitem.wpn=wGARROW;
7286 16 break;
7287
7288 case iBrang:
7289 16 tempitem.power=0;
7290 16 tempitem.wpn=wBRANG;
7291 16 tempitem.misc1=36;
7292 16 break;
7293
7294 case iMBrang:
7295 16 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7296 16 tempitem.power=0;
7297 16 tempitem.wpn=wMBRANG;
7298 16 break;
7299
7300 case iFBrang:
7301 16 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7302 16 tempitem.power=2;
7303 16 tempitem.wpn=wFBRANG;
7304 16 break;
7305
7306 case iBoots:
7307 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7308 16 tempitem.power=7;
7309 16 break;
7310
7311 case iWand:
7312 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7313 16 tempitem.power=2;
7314 16 tempitem.wpn=wWAND;
7315 16 tempitem.wpn3=wMAGIC;
7316 16 break;
7317
7318 case iBCandle:
7319 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7320 16 tempitem.power=1;
7321 16 tempitem.flags|=(ITEM_GAMEDATA|ITEM_FLAG1);
7322 16 tempitem.wpn3=wFIRE;
7323 16 break;
7324
7325 case iRCandle:
7326 16 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7327 16 tempitem.power=1;
7328 16 tempitem.wpn3=wFIRE;
7329 16 break;
7330
7331 case iSword:
7332 16 tempitem.power=1;
7333 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7334 16 tempitem.wpn=tempitem.wpn3=wSWORD;
7335 16 tempitem.wpn2=wSWORDSLASH;
7336 16 break;
7337
7338 case iWSword:
7339 16 tempitem.power=2;
7340 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7341 16 tempitem.wpn=tempitem.wpn3=wWSWORD;
7342 16 tempitem.wpn2=wWSWORDSLASH;
7343 16 break;
7344
7345 case iMSword:
7346 16 tempitem.power=4;
7347 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7348 16 tempitem.wpn=tempitem.wpn3=wMSWORD;
7349 16 tempitem.wpn2=wMSWORDSLASH;
7350 16 break;
7351
7352 case iXSword:
7353 16 tempitem.power=8;
7354 16 tempitem.flags|= ITEM_FLAG4 |ITEM_FLAG2;
7355 16 tempitem.wpn=tempitem.wpn3=wXSWORD;
7356 16 tempitem.wpn2=wXSWORDSLASH;
7357 16 break;
7358
7359 case iDivineProtection:
7360 16 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG1 : 0;
7361 16 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? ITEM_FLAG2 : 0;
7362 16 tempitem.wpn=wDIVINEPROTECTION1A;
7363 16 tempitem.wpn2=wDIVINEPROTECTION1B;
7364 16 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7365 16 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7366 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7367 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7368 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7369 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7370 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7371 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7372 16 tempitem.misc1=512;
7373 16 tempitem.cost_amount[0]=64;
7374 16 break;
7375
7376 case iLens:
7377 16 tempitem.misc1=60;
7378 16 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? 0 : ITEM_RUPEE_MAGIC;
7379 16 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7380 16 break;
7381
7382 case iArrow:
7383 16 tempitem.power=2;
7384 16 tempitem.wpn=wARROW;
7385 16 break;
7386
7387 case iHoverBoots:
7388 16 tempitem.misc1=45;
7389 16 tempitem.wpn=iwHover;
7390 16 break;
7391
7392 case iDivineFire:
7393 16 tempitem.power=8;
7394 16 tempitem.wpn=wDIVINEFIRE1A;
7395 16 tempitem.wpn2=wDIVINEFIRE1B;
7396 16 tempitem.wpn3=wDIVINEFIRES1A;
7397 16 tempitem.wpn4=wDIVINEFIRES1B;
7398 16 tempitem.misc1 = 32;
7399 16 tempitem.misc2 = 200;
7400 16 tempitem.cost_amount[0]=32;
7401 16 break;
7402
7403 case iDivineEscape:
7404 16 tempitem.cost_amount[0]=32;
7405 16 break;
7406
7407 case iHookshot:
7408 16 tempitem.power=0;
7409 16 tempitem.flags&=~ITEM_FLAG1;
7410 16 tempitem.wpn=wHSHEAD;
7411 16 tempitem.wpn2=wHSCHAIN_H;
7412 16 tempitem.wpn4=wHSHANDLE;
7413 16 tempitem.wpn3=wHSCHAIN_V;
7414 16 tempitem.misc1=50;
7415 16 tempitem.misc2=100;
7416 16 break;
7417
7418 case iLongshot:
7419 16 tempitem.power=0;
7420 16 tempitem.flags&=~ITEM_FLAG1;
7421 16 tempitem.wpn=wLSHEAD;
7422 16 tempitem.wpn2=wLSCHAIN_H;
7423 16 tempitem.wpn4=wLSHANDLE;
7424 16 tempitem.wpn3=wLSCHAIN_V;
7425 16 tempitem.misc1=99;
7426 16 tempitem.misc2=100;
7427 16 break;
7428
7429 case iHammer:
7430 16 tempitem.power=4;
7431 16 tempitem.wpn=wHAMMER;
7432 16 tempitem.wpn2=iwHammerSmack;
7433 16 break;
7434
7435 case iCByrna:
7436 16 tempitem.power=1;
7437 16 tempitem.wpn=wCBYRNA;
7438 16 tempitem.wpn2=wCBYRNASLASH;
7439 16 tempitem.wpn3=wCBYRNAORB;
7440 16 tempitem.misc1=4;
7441 16 tempitem.misc2=16;
7442 16 tempitem.misc3=1;
7443 16 tempitem.cost_amount[0]=1;
7444 16 break;
7445
7446 case iWhistle:
7447 16 tempitem.wpn=wWIND;
7448 16 tempitem.misc1=3;
7449 16 tempitem.flags|=ITEM_FLAG1;
7450 16 break;
7451
7452 case iBRing:
7453 16 tempitem.power=2;
7454 16 tempitem.misc1=spBLUE;
7455 16 break;
7456
7457 case iRRing:
7458 16 tempitem.power=4;
7459 16 tempitem.misc1=spRED;
7460 16 break;
7461
7462 case iGRing:
7463 16 tempitem.power=8;
7464 16 tempitem.misc1=spGOLD;
7465 16 break;
7466
7467 case iSpinScroll:
7468 16 tempitem.power = 2;
7469 16 tempitem.misc1 = 1;
7470 16 break;
7471
7472 case iL2SpinScroll:
7473 16 tempitem.family=itype_spinscroll2;
7474 16 tempitem.fam_type=1;
7475 16 tempitem.cost_amount[0]=8;
7476 16 tempitem.power=2;
7477 16 tempitem.misc1 = 20;
7478 16 break;
7479
7480 case iQuakeScroll:
7481 16 tempitem.misc1=0x10;
7482 16 tempitem.misc2=64;
7483 16 break;
7484
7485 case iL2QuakeScroll:
7486 16 tempitem.family=itype_quakescroll2;
7487 16 tempitem.fam_type=1;
7488 16 tempitem.power = 2;
7489 16 tempitem.misc1=0x20;
7490 16 tempitem.misc2=192;
7491 16 tempitem.cost_amount[0]=8;
7492 16 break;
7493
7494 case iChargeRing:
7495 16 tempitem.misc1=64;
7496 16 tempitem.misc2=128;
7497 16 break;
7498
7499 case iL2ChargeRing:
7500 16 tempitem.misc1=32;
7501 16 tempitem.misc2=64;
7502 16 break;
7503
7504 case iOldGlove:
7505 16 tempitem.flags |= ITEM_FLAG1;
7506
7507 //fallthrough
7508 case iBombBagL4:
7509 case iWalletL3:
7510 case iQuiverL4:
7511 case iBracelet:
7512 80 tempitem.power = 1;
7513 80 break;
7514
7515 case iL2Bracelet:
7516 16 tempitem.power = 2;
7517 16 break;
7518
7519 case iMKey:
7520 16 tempitem.power=0xFF;
7521 16 tempitem.flags |= ITEM_FLAG1;
7522 16 break;
7523 }
7524 4096 }
7525
7526
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 7)
7527 {
7528
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 4032 times.
4096 switch(i)
7529 {
7530 case iStoneAgony:
7531 case iStompBoots:
7532 case iPerilRing:
7533 case iWhimsicalRing:
7534 {
7535 64 reset_itembuf(&tempitem, i);
7536 64 strcpy(item_string[i],old_item_string[i]);
7537 64 break;
7538 }
7539 }
7540 4096 }
7541
7542
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 8) // May 2007: Some corrections.
7543 {
7544
7/7
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 3968 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
4096 switch(i)
7545 {
7546 case iMShield:
7547 16 tempitem.misc1|=shFLAME;
7548 16 tempitem.misc2|=shFIREBALL|shMAGIC;
7549
7550
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_qr(qr_SWORDMIRROR))
7551 {
7552 tempitem.misc2 |= shSWORD;
7553 }
7554
7555 // fallthrough
7556 case iShield:
7557 32 tempitem.misc1|=shFIREBALL|shSWORD|shMAGIC;
7558
7559 // fallthrough
7560 case iSShield:
7561 48 tempitem.misc1|=shROCK|shARROW|shBRANG|shSCRIPT;
7562
7563
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7564 {
7565 tempitem.misc2 |= shROCK;
7566 }
7567
7568 48 break;
7569
7570 case iWhispRing:
7571 16 tempitem.power=1;
7572 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7573 16 tempitem.misc1 = 3;
7574 16 break;
7575
7576 case iL2WhispRing:
7577 16 tempitem.power=0;
7578 16 tempitem.flags|=ITEM_GAMEDATA|ITEM_FLAG1;
7579 16 tempitem.misc1 = 3;
7580 16 break;
7581
7582 case iL2Ladder:
7583 case iBow:
7584 case iCByrna:
7585 48 tempitem.power = 1;
7586 48 break;
7587 }
7588 4096 }
7589
7590
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 9 && i==iClock)
7591 {
7592 16 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7593 16 }
7594
7595 //add the misc flag for bomb
7596
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4080 times.
✓ Branch 3 taken 16 times.
33024 if(s_version < 10 && tempitem.family == itype_bomb)
7597 {
7598 16 tempitem.flags = (tempitem.flags & ~ITEM_FLAG1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? ITEM_FLAG1 : 0);
7599 16 }
7600
7601
4/4
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 28928 times.
✓ Branch 2 taken 4064 times.
✓ Branch 3 taken 32 times.
33024 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7602 {
7603 32 tempitem.flags = (tempitem.fam_type ? ITEM_GAMEDATA : 0);
7604 32 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7605 32 }
7606
7607
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 12) // June 2007: More Misc. attributes.
7608 {
7609
5/5
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4016 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
4096 switch(i)
7610 {
7611 case iFBrang:
7612 16 tempitem.misc4 |= shFIREBALL|shSWORD|shMAGIC;
7613
7614 //fallthrough
7615 case iMBrang:
7616 32 tempitem.misc3 |= shSWORD|shMAGIC;
7617
7618 //fallthrough
7619 case iHookshot:
7620 case iLongshot:
7621 //fallthrough
7622 64 tempitem.misc3 |= shFIREBALL;
7623
7624 case iBrang:
7625 80 tempitem.misc3 |= shBRANG|shROCK|shARROW;
7626 80 break;
7627 }
7628
7629
16/16
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 32 times.
✓ Branch 5 taken 48 times.
✓ Branch 6 taken 48 times.
✓ Branch 7 taken 1740 times.
✓ Branch 8 taken 16 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
✓ Branch 11 taken 16 times.
✓ Branch 12 taken 16 times.
✓ Branch 13 taken 64 times.
✓ Branch 14 taken 32 times.
✓ Branch 15 taken 1956 times.
4096 switch(tempitem.family)
7630 {
7631 case itype_hoverboots:
7632 16 tempitem.usesound = WAV_ZN1HOVER;
7633 16 break;
7634
7635 case itype_wand:
7636 16 tempitem.usesound = WAV_WAND;
7637 16 break;
7638
7639 case itype_book:
7640 16 tempitem.usesound = WAV_FIRE;
7641 16 break;
7642
7643 case itype_arrow:
7644 48 tempitem.usesound = WAV_ARROW;
7645 48 break;
7646
7647 case itype_hookshot:
7648 32 tempitem.usesound = WAV_HOOKSHOT;
7649 32 break;
7650
7651 case itype_brang:
7652 48 tempitem.usesound = WAV_BRANG;
7653 48 break;
7654
7655 case itype_shield:
7656 48 tempitem.usesound = WAV_CHINK;
7657 48 break;
7658
7659 case itype_sword:
7660 1740 tempitem.usesound = WAV_SWORD;
7661 1740 break;
7662
7663 case itype_whistle:
7664 16 tempitem.usesound = WAV_WHISTLE;
7665 16 break;
7666
7667 case itype_hammer:
7668 16 tempitem.usesound = WAV_HAMMER;
7669 16 break;
7670
7671 case itype_divinefire:
7672 16 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7673 16 break;
7674
7675 case itype_divineescape:
7676 16 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7677 16 break;
7678
7679 case itype_divineprotection:
7680 16 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7681 16 break;
7682
7683 case itype_bomb:
7684 case itype_sbomb:
7685 case itype_quakescroll:
7686 case itype_quakescroll2:
7687 64 tempitem.usesound = WAV_BOMB;
7688 64 break;
7689
7690 case itype_spinscroll:
7691 case itype_spinscroll2:
7692 32 tempitem.usesound = WAV_ZN1SPINATTACK;
7693 32 break;
7694 }
7695 4096 }
7696
7697
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 13) // July 2007
7698 {
7699
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7700 {
7701 16 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7702 16 tempitem.power = 1;
7703 16 tempitem.flags|=ITEM_FLAG1;
7704 16 }
7705
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_wand)
7706 16 tempitem.flags|=ITEM_FLAG1;
7707
2/2
✓ Branch 0 taken 4048 times.
✓ Branch 1 taken 16 times.
4064 else if(tempitem.family == itype_book)
7708 {
7709 16 tempitem.flags|=ITEM_FLAG1;
7710 16 tempitem.power = 2;
7711 16 }
7712 4096 }
7713
7714
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 14) // August 2007
7715 {
7716
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
4096 if(tempitem.family == itype_fairy)
7717 {
7718 32 tempitem.usesound = WAV_SCALE;
7719
7720
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32 times.
32 if(tempitem.fam_type)
7721 32 tempitem.misc3=50;
7722 32 }
7723
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_potion)
7724 {
7725 32 tempitem.flags |= ITEM_GAINOLD;
7726 32 }
7727 4096 }
7728
7729
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 17) // November 2007
7730 {
7731
3/4
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 4064 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32 times.
4096 if(tempitem.family == itype_candle && !tempitem.wpn3)
7732 {
7733 tempitem.wpn3 = wFIRE;
7734 }
7735
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 4048 times.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 16 times.
4096 else if(tempitem.family == itype_arrow && tempitem.power>4)
7736 {
7737 16 tempitem.flags|=ITEM_FLAG1;
7738 16 }
7739 4096 }
7740
7741
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 18) // New Year's Eve 2007
7742 {
7743
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_whistle)
7744 16 tempitem.misc2 = 8; // Use the Whistle warp ring
7745
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4064 times.
4080 else if(tempitem.family == itype_bait)
7746 16 tempitem.misc1 = 768; // Frames until it goes
7747
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 32 times.
4064 else if(tempitem.family == itype_triforcepiece)
7748 {
7749
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
32 if(tempitem.flags & ITEM_GAMEDATA)
7750 {
7751 16 tempitem.misc2 = 1; // Cutscene 1
7752 16 tempitem.flags |= ITEM_FLAG1; // Side Warp Out
7753 16 }
7754 32 }
7755 4096 }
7756
7757
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 19) // January 2008
7758 {
7759
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7760 {
7761 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)?ITEM_FLAG3:0;
7762 16 tempitem.flags |= get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)?ITEM_FLAG4:0;
7763 16 }
7764 4096 }
7765
7766
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 20) // October 2008
7767 {
7768
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divineprotection)
7769 {
7770 16 tempitem.wpn6=wDIVINEPROTECTION2A;
7771 16 tempitem.wpn7=wDIVINEPROTECTION2B;
7772 16 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7773 16 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7774 16 tempitem.wpn5 = iwDivineProtectionShieldFront;
7775 16 tempitem.wpn10 = iwDivineProtectionShieldBack;
7776 16 }
7777 4096 }
7778
7779
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 21) // November 2008
7780 {
7781
1/2
✓ Branch 0 taken 4096 times.
✗ Branch 1 not taken.
4096 if(tempitem.flags & 0x0100) // ITEM_SLASH
7782 {
7783 tempitem.flags &= ~0x0100;
7784
7785 if(tempitem.family == itype_sword ||
7786 tempitem.family == itype_wand ||
7787 tempitem.family == itype_candle ||
7788 tempitem.family == itype_cbyrna)
7789 {
7790 tempitem.flags |= ITEM_FLAG4;
7791 }
7792 }
7793 4096 }
7794
7795
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 22) // September 2009
7796 {
7797
4/4
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 4064 times.
4096 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7798 {
7799 32 tempitem.misc3 = tempitem.power/2;
7800 32 }
7801 4096 }
7802
7803
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 23) // March 2011
7804 {
7805
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4080 times.
4096 if(tempitem.family == itype_divinefire)
7806 16 tempitem.wpn5 = wFIRE;
7807
2/2
✓ Branch 0 taken 4064 times.
✓ Branch 1 taken 16 times.
4080 else if(tempitem.family == itype_book)
7808 16 tempitem.wpn2 = wFIRE;
7809 4096 }
7810
7811 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7812 // whether it was or not, and a lot of existing quests depended on the
7813 // incorrect behavior.
7814
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 4096 times.
33024 if(s_version < 25) // January 2012
7815 {
7816
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 64 times.
4096 if(tempitem.family == itype_bombbag)
7817 64 tempitem.flags |= 16;
7818
7819
2/2
✓ Branch 0 taken 4080 times.
✓ Branch 1 taken 16 times.
4096 if(tempitem.family == itype_divinefire)
7820 16 tempitem.flags |= ITEM_FLAG3; // Sideview gravity flag
7821 4096 }
7822
7823
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7824 {
7825
60/60
✓ Branch 0 taken 7811 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 222 times.
✓ Branch 4 taken 138 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 184 times.
✓ Branch 7 taken 183 times.
✓ Branch 8 taken 107 times.
✓ Branch 9 taken 302 times.
✓ Branch 10 taken 276 times.
✓ Branch 11 taken 183 times.
✓ Branch 12 taken 283 times.
✓ Branch 13 taken 184 times.
✓ Branch 14 taken 92 times.
✓ Branch 15 taken 184 times.
✓ Branch 16 taken 107 times.
✓ Branch 17 taken 92 times.
✓ Branch 18 taken 279 times.
✓ Branch 19 taken 93 times.
✓ Branch 20 taken 94 times.
✓ Branch 21 taken 184 times.
✓ Branch 22 taken 92 times.
✓ Branch 23 taken 93 times.
✓ Branch 24 taken 92 times.
✓ Branch 25 taken 92 times.
✓ Branch 26 taken 92 times.
✓ Branch 27 taken 107 times.
✓ Branch 28 taken 92 times.
✓ Branch 29 taken 93 times.
✓ Branch 30 taken 92 times.
✓ Branch 31 taken 93 times.
✓ Branch 32 taken 184 times.
✓ Branch 33 taken 368 times.
✓ Branch 34 taken 94 times.
✓ Branch 35 taken 92 times.
✓ Branch 36 taken 168 times.
✓ Branch 37 taken 368 times.
✓ Branch 38 taken 92 times.
✓ Branch 39 taken 92 times.
✓ Branch 40 taken 92 times.
✓ Branch 41 taken 92 times.
✓ Branch 42 taken 92 times.
✓ Branch 43 taken 185 times.
✓ Branch 44 taken 184 times.
✓ Branch 45 taken 92 times.
✓ Branch 46 taken 277 times.
✓ Branch 47 taken 278 times.
✓ Branch 48 taken 372 times.
✓ Branch 49 taken 92 times.
✓ Branch 50 taken 92 times.
✓ Branch 51 taken 92 times.
✓ Branch 52 taken 92 times.
✓ Branch 53 taken 92 times.
✓ Branch 54 taken 93 times.
✓ Branch 55 taken 2541 times.
✓ Branch 56 taken 983 times.
✓ Branch 57 taken 277 times.
✓ Branch 58 taken 1135 times.
✓ Branch 59 taken 2617 times.
23808 switch(tempitem.family)
7826 {
7827 case itype_sword:
7828 {
7829 7811 tempitem.flags &= ~(ITEM_FLAG5);
7830 7811 tempitem.misc3 = 0;
7831 7811 tempitem.misc4 = 0;
7832 7811 tempitem.misc5 = 0;
7833 7811 tempitem.misc6 = 0;
7834 7811 tempitem.misc7 = 0;
7835 7811 tempitem.misc8 = 0;
7836 7811 tempitem.misc9 = 0;
7837 7811 tempitem.misc10 = 0;
7838 7811 tempitem.wpn4 = 0;
7839 7811 tempitem.wpn5 = 0;
7840 7811 tempitem.wpn6 = 0;
7841 7811 tempitem.wpn7 = 0;
7842 7811 tempitem.wpn8 = 0;
7843 7811 tempitem.wpn9 = 0;
7844 7811 tempitem.wpn10 = 0;
7845 7811 break;
7846 }
7847 case itype_brang:
7848 {
7849 277 tempitem.flags &= ~(ITEM_FLAG4 | ITEM_FLAG5);
7850 277 tempitem.misc2 = 0;
7851 277 tempitem.misc5 = 0;
7852 277 tempitem.misc6 = 0;
7853 277 tempitem.misc7 = 0;
7854 277 tempitem.misc8 = 0;
7855 277 tempitem.misc9 = 0;
7856 277 tempitem.misc10 = 0;
7857 277 tempitem.wpn4 = 0;
7858 277 tempitem.wpn5 = 0;
7859 277 tempitem.wpn6 = 0;
7860 277 tempitem.wpn7 = 0;
7861 277 tempitem.wpn8 = 0;
7862 277 tempitem.wpn9 = 0;
7863 277 tempitem.wpn10 = 0;
7864 277 break;
7865 }
7866 case itype_arrow:
7867 {
7868 274 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7869 274 tempitem.misc2 = 0;
7870 274 tempitem.misc3 = 0;
7871 274 tempitem.misc4 = 0;
7872 274 tempitem.misc5 = 0;
7873 274 tempitem.misc6 = 0;
7874 274 tempitem.misc7 = 0;
7875 274 tempitem.misc8 = 0;
7876 274 tempitem.misc9 = 0;
7877 274 tempitem.misc10 = 0;
7878 274 tempitem.wpn4 = 0;
7879 274 tempitem.wpn5 = 0;
7880 274 tempitem.wpn6 = 0;
7881 274 tempitem.wpn7 = 0;
7882 274 tempitem.wpn8 = 0;
7883 274 tempitem.wpn9 = 0;
7884 274 tempitem.wpn10 = 0;
7885 274 break;
7886 }
7887 case itype_candle:
7888 {
7889 222 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG5);
7890 222 tempitem.misc1 = 0;
7891 222 tempitem.misc2 = 0;
7892 222 tempitem.misc3 = 0;
7893 222 tempitem.misc4 = 0;
7894 222 tempitem.misc5 = 0;
7895 222 tempitem.misc6 = 0;
7896 222 tempitem.misc7 = 0;
7897 222 tempitem.misc8 = 0;
7898 222 tempitem.misc9 = 0;
7899 222 tempitem.misc10 = 0;
7900 222 tempitem.wpn4 = 0;
7901 222 tempitem.wpn5 = 0;
7902 222 tempitem.wpn6 = 0;
7903 222 tempitem.wpn7 = 0;
7904 222 tempitem.wpn8 = 0;
7905 222 tempitem.wpn9 = 0;
7906 222 tempitem.wpn10 = 0;
7907 222 break;
7908 }
7909 case itype_whistle:
7910 {
7911 138 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7912 138 tempitem.misc3 = 0;
7913 138 tempitem.misc4 = 0;
7914 138 tempitem.misc5 = 0;
7915 138 tempitem.misc6 = 0;
7916 138 tempitem.misc7 = 0;
7917 138 tempitem.misc8 = 0;
7918 138 tempitem.misc9 = 0;
7919 138 tempitem.misc10 = 0;
7920 138 tempitem.wpn2 = 0;
7921 138 tempitem.wpn3 = 0;
7922 138 tempitem.wpn4 = 0;
7923 138 tempitem.wpn5 = 0;
7924 138 tempitem.wpn6 = 0;
7925 138 tempitem.wpn7 = 0;
7926 138 tempitem.wpn8 = 0;
7927 138 tempitem.wpn9 = 0;
7928 138 tempitem.wpn10 = 0;
7929 138 break;
7930 }
7931 case itype_bait:
7932 {
7933 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7934 93 tempitem.misc2 = 0;
7935 93 tempitem.misc3 = 0;
7936 93 tempitem.misc4 = 0;
7937 93 tempitem.misc5 = 0;
7938 93 tempitem.misc6 = 0;
7939 93 tempitem.misc7 = 0;
7940 93 tempitem.misc8 = 0;
7941 93 tempitem.misc9 = 0;
7942 93 tempitem.misc10 = 0;
7943 93 tempitem.wpn2 = 0;
7944 93 tempitem.wpn3 = 0;
7945 93 tempitem.wpn4 = 0;
7946 93 tempitem.wpn5 = 0;
7947 93 tempitem.wpn6 = 0;
7948 93 tempitem.wpn7 = 0;
7949 93 tempitem.wpn8 = 0;
7950 93 tempitem.wpn9 = 0;
7951 93 tempitem.wpn10 = 0;
7952 93 break;
7953 }
7954 case itype_letter:
7955 {
7956 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7957 184 tempitem.misc1 = 0;
7958 184 tempitem.misc2 = 0;
7959 184 tempitem.misc3 = 0;
7960 184 tempitem.misc4 = 0;
7961 184 tempitem.misc5 = 0;
7962 184 tempitem.misc6 = 0;
7963 184 tempitem.misc7 = 0;
7964 184 tempitem.misc8 = 0;
7965 184 tempitem.misc9 = 0;
7966 184 tempitem.misc10 = 0;
7967 184 tempitem.wpn = 0;
7968 184 tempitem.wpn2 = 0;
7969 184 tempitem.wpn3 = 0;
7970 184 tempitem.wpn4 = 0;
7971 184 tempitem.wpn5 = 0;
7972 184 tempitem.wpn6 = 0;
7973 184 tempitem.wpn7 = 0;
7974 184 tempitem.wpn8 = 0;
7975 184 tempitem.wpn9 = 0;
7976 184 tempitem.wpn10 = 0;
7977 184 break;
7978 }
7979 case itype_potion:
7980 {
7981 183 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
7982 183 tempitem.misc3 = 0;
7983 183 tempitem.misc4 = 0;
7984 183 tempitem.misc5 = 0;
7985 183 tempitem.misc6 = 0;
7986 183 tempitem.misc7 = 0;
7987 183 tempitem.misc8 = 0;
7988 183 tempitem.misc9 = 0;
7989 183 tempitem.misc10 = 0;
7990 183 tempitem.wpn = 0;
7991 183 tempitem.wpn2 = 0;
7992 183 tempitem.wpn3 = 0;
7993 183 tempitem.wpn4 = 0;
7994 183 tempitem.wpn5 = 0;
7995 183 tempitem.wpn6 = 0;
7996 183 tempitem.wpn7 = 0;
7997 183 tempitem.wpn8 = 0;
7998 183 tempitem.wpn9 = 0;
7999 183 tempitem.wpn10 = 0;
8000 183 break;
8001 }
8002 case itype_wand:
8003 {
8004 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8005 107 tempitem.misc1 = 0;
8006 107 tempitem.misc2 = 0;
8007 107 tempitem.misc3 = 0;
8008 107 tempitem.misc4 = 0;
8009 107 tempitem.misc5 = 0;
8010 107 tempitem.misc6 = 0;
8011 107 tempitem.misc7 = 0;
8012 107 tempitem.misc8 = 0;
8013 107 tempitem.misc9 = 0;
8014 107 tempitem.misc10 = 0;
8015 107 tempitem.wpn4 = 0;
8016 107 tempitem.wpn5 = 0;
8017 107 tempitem.wpn6 = 0;
8018 107 tempitem.wpn7 = 0;
8019 107 tempitem.wpn8 = 0;
8020 107 tempitem.wpn9 = 0;
8021 107 tempitem.wpn10 = 0;
8022 107 break;
8023 }
8024 case itype_ring:
8025 {
8026 302 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8027 302 tempitem.misc2 = 0;
8028 302 tempitem.misc3 = 0;
8029 302 tempitem.misc4 = 0;
8030 302 tempitem.misc5 = 0;
8031 302 tempitem.misc6 = 0;
8032 302 tempitem.misc7 = 0;
8033 302 tempitem.misc8 = 0;
8034 302 tempitem.misc9 = 0;
8035 302 tempitem.misc10 = 0;
8036 302 tempitem.wpn = 0;
8037 302 tempitem.wpn2 = 0;
8038 302 tempitem.wpn3 = 0;
8039 302 tempitem.wpn4 = 0;
8040 302 tempitem.wpn5 = 0;
8041 302 tempitem.wpn6 = 0;
8042 302 tempitem.wpn7 = 0;
8043 302 tempitem.wpn8 = 0;
8044 302 tempitem.wpn9 = 0;
8045 302 tempitem.wpn10 = 0;
8046 302 break;
8047 }
8048 case itype_wallet:
8049 {
8050 276 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8051 276 tempitem.misc3 = 0;
8052 276 tempitem.misc4 = 0;
8053 276 tempitem.misc5 = 0;
8054 276 tempitem.misc6 = 0;
8055 276 tempitem.misc7 = 0;
8056 276 tempitem.misc8 = 0;
8057 276 tempitem.misc9 = 0;
8058 276 tempitem.misc10 = 0;
8059 276 tempitem.wpn = 0;
8060 276 tempitem.wpn2 = 0;
8061 276 tempitem.wpn3 = 0;
8062 276 tempitem.wpn4 = 0;
8063 276 tempitem.wpn5 = 0;
8064 276 tempitem.wpn6 = 0;
8065 276 tempitem.wpn7 = 0;
8066 276 tempitem.wpn8 = 0;
8067 276 tempitem.wpn9 = 0;
8068 276 tempitem.wpn10 = 0;
8069 276 break;
8070 }
8071 case itype_amulet:
8072 {
8073 183 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8074 183 tempitem.misc1 = 0;
8075 183 tempitem.misc2 = 0;
8076 183 tempitem.misc3 = 0;
8077 183 tempitem.misc4 = 0;
8078 183 tempitem.misc5 = 0;
8079 183 tempitem.misc6 = 0;
8080 183 tempitem.misc7 = 0;
8081 183 tempitem.misc8 = 0;
8082 183 tempitem.misc9 = 0;
8083 183 tempitem.misc10 = 0;
8084 183 tempitem.wpn = 0;
8085 183 tempitem.wpn2 = 0;
8086 183 tempitem.wpn3 = 0;
8087 183 tempitem.wpn4 = 0;
8088 183 tempitem.wpn5 = 0;
8089 183 tempitem.wpn6 = 0;
8090 183 tempitem.wpn7 = 0;
8091 183 tempitem.wpn8 = 0;
8092 183 tempitem.wpn9 = 0;
8093 183 tempitem.wpn10 = 0;
8094 183 break;
8095 }
8096 case itype_shield:
8097 {
8098 283 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8099 283 tempitem.misc3 = 0;
8100 283 tempitem.misc4 = 0;
8101 283 tempitem.misc5 = 0;
8102 283 tempitem.misc6 = 0;
8103 283 tempitem.misc7 = 0;
8104 283 tempitem.misc8 = 0;
8105 283 tempitem.misc9 = 0;
8106 283 tempitem.misc10 = 0;
8107 283 tempitem.wpn = 0;
8108 283 tempitem.wpn2 = 0;
8109 283 tempitem.wpn3 = 0;
8110 283 tempitem.wpn4 = 0;
8111 283 tempitem.wpn5 = 0;
8112 283 tempitem.wpn6 = 0;
8113 283 tempitem.wpn7 = 0;
8114 283 tempitem.wpn8 = 0;
8115 283 tempitem.wpn9 = 0;
8116 283 tempitem.wpn10 = 0;
8117 283 break;
8118 }
8119 case itype_bow:
8120 {
8121 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8122 184 tempitem.misc1 = 0;
8123 184 tempitem.misc2 = 0;
8124 184 tempitem.misc3 = 0;
8125 184 tempitem.misc4 = 0;
8126 184 tempitem.misc5 = 0;
8127 184 tempitem.misc6 = 0;
8128 184 tempitem.misc7 = 0;
8129 184 tempitem.misc8 = 0;
8130 184 tempitem.misc9 = 0;
8131 184 tempitem.misc10 = 0;
8132 184 tempitem.wpn = 0;
8133 184 tempitem.wpn2 = 0;
8134 184 tempitem.wpn3 = 0;
8135 184 tempitem.wpn4 = 0;
8136 184 tempitem.wpn5 = 0;
8137 184 tempitem.wpn6 = 0;
8138 184 tempitem.wpn7 = 0;
8139 184 tempitem.wpn8 = 0;
8140 184 tempitem.wpn9 = 0;
8141 184 tempitem.wpn10 = 0;
8142 184 break;
8143 }
8144 case itype_raft:
8145 {
8146 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8147 92 tempitem.misc1 = 0;
8148 92 tempitem.misc2 = 0;
8149 92 tempitem.misc3 = 0;
8150 92 tempitem.misc4 = 0;
8151 92 tempitem.misc5 = 0;
8152 92 tempitem.misc6 = 0;
8153 92 tempitem.misc7 = 0;
8154 92 tempitem.misc8 = 0;
8155 92 tempitem.misc9 = 0;
8156 92 tempitem.misc10 = 0;
8157 92 tempitem.wpn = 0;
8158 92 tempitem.wpn2 = 0;
8159 92 tempitem.wpn3 = 0;
8160 92 tempitem.wpn4 = 0;
8161 92 tempitem.wpn5 = 0;
8162 92 tempitem.wpn6 = 0;
8163 92 tempitem.wpn7 = 0;
8164 92 tempitem.wpn8 = 0;
8165 92 tempitem.wpn9 = 0;
8166 92 tempitem.wpn10 = 0;
8167 92 break;
8168 }
8169 case itype_ladder:
8170 {
8171 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8172 184 tempitem.misc1 = 0;
8173 184 tempitem.misc2 = 0;
8174 184 tempitem.misc3 = 0;
8175 184 tempitem.misc4 = 0;
8176 184 tempitem.misc5 = 0;
8177 184 tempitem.misc6 = 0;
8178 184 tempitem.misc7 = 0;
8179 184 tempitem.misc8 = 0;
8180 184 tempitem.misc9 = 0;
8181 184 tempitem.misc10 = 0;
8182 184 tempitem.wpn = 0;
8183 184 tempitem.wpn2 = 0;
8184 184 tempitem.wpn3 = 0;
8185 184 tempitem.wpn4 = 0;
8186 184 tempitem.wpn5 = 0;
8187 184 tempitem.wpn6 = 0;
8188 184 tempitem.wpn7 = 0;
8189 184 tempitem.wpn8 = 0;
8190 184 tempitem.wpn9 = 0;
8191 184 tempitem.wpn10 = 0;
8192 184 break;
8193 }
8194 case itype_book:
8195 {
8196 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8197 107 tempitem.misc1 = 0;
8198 107 tempitem.misc2 = 0;
8199 107 tempitem.misc3 = 0;
8200 107 tempitem.misc4 = 0;
8201 107 tempitem.misc5 = 0;
8202 107 tempitem.misc6 = 0;
8203 107 tempitem.misc7 = 0;
8204 107 tempitem.misc8 = 0;
8205 107 tempitem.misc9 = 0;
8206 107 tempitem.misc10 = 0;
8207 107 tempitem.wpn3 = 0;
8208 107 tempitem.wpn4 = 0;
8209 107 tempitem.wpn5 = 0;
8210 107 tempitem.wpn6 = 0;
8211 107 tempitem.wpn7 = 0;
8212 107 tempitem.wpn8 = 0;
8213 107 tempitem.wpn9 = 0;
8214 107 tempitem.wpn10 = 0;
8215 107 break;
8216 }
8217 case itype_magickey:
8218 {
8219 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8220 92 tempitem.misc1 = 0;
8221 92 tempitem.misc2 = 0;
8222 92 tempitem.misc3 = 0;
8223 92 tempitem.misc4 = 0;
8224 92 tempitem.misc5 = 0;
8225 92 tempitem.misc6 = 0;
8226 92 tempitem.misc7 = 0;
8227 92 tempitem.misc8 = 0;
8228 92 tempitem.misc9 = 0;
8229 92 tempitem.misc10 = 0;
8230 92 tempitem.wpn = 0;
8231 92 tempitem.wpn2 = 0;
8232 92 tempitem.wpn3 = 0;
8233 92 tempitem.wpn4 = 0;
8234 92 tempitem.wpn5 = 0;
8235 92 tempitem.wpn6 = 0;
8236 92 tempitem.wpn7 = 0;
8237 92 tempitem.wpn8 = 0;
8238 92 tempitem.wpn9 = 0;
8239 92 tempitem.wpn10 = 0;
8240 92 break;
8241 }
8242 case itype_bracelet:
8243 {
8244 279 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8245 279 tempitem.misc1 = 0;
8246 279 tempitem.misc2 = 0;
8247 279 tempitem.misc3 = 0;
8248 279 tempitem.misc4 = 0;
8249 279 tempitem.misc5 = 0;
8250 279 tempitem.misc6 = 0;
8251 279 tempitem.misc7 = 0;
8252 279 tempitem.misc8 = 0;
8253 279 tempitem.misc9 = 0;
8254 279 tempitem.misc10 = 0;
8255 279 tempitem.wpn = 0;
8256 279 tempitem.wpn2 = 0;
8257 279 tempitem.wpn3 = 0;
8258 279 tempitem.wpn4 = 0;
8259 279 tempitem.wpn5 = 0;
8260 279 tempitem.wpn6 = 0;
8261 279 tempitem.wpn7 = 0;
8262 279 tempitem.wpn8 = 0;
8263 279 tempitem.wpn9 = 0;
8264 279 tempitem.wpn10 = 0;
8265 279 break;
8266 }
8267 case itype_flippers:
8268 {
8269 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8270 93 tempitem.misc1 = 0;
8271 93 tempitem.misc2 = 0;
8272 93 tempitem.misc3 = 0;
8273 93 tempitem.misc4 = 0;
8274 93 tempitem.misc5 = 0;
8275 93 tempitem.misc6 = 0;
8276 93 tempitem.misc7 = 0;
8277 93 tempitem.misc8 = 0;
8278 93 tempitem.misc9 = 0;
8279 93 tempitem.misc10 = 0;
8280 93 tempitem.wpn = 0;
8281 93 tempitem.wpn2 = 0;
8282 93 tempitem.wpn3 = 0;
8283 93 tempitem.wpn4 = 0;
8284 93 tempitem.wpn5 = 0;
8285 93 tempitem.wpn6 = 0;
8286 93 tempitem.wpn7 = 0;
8287 93 tempitem.wpn8 = 0;
8288 93 tempitem.wpn9 = 0;
8289 93 tempitem.wpn10 = 0;
8290 93 break;
8291 }
8292 case itype_boots:
8293 {
8294 94 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8295 94 tempitem.misc1 = 0;
8296 94 tempitem.misc2 = 0;
8297 94 tempitem.misc3 = 0;
8298 94 tempitem.misc4 = 0;
8299 94 tempitem.misc5 = 0;
8300 94 tempitem.misc6 = 0;
8301 94 tempitem.misc7 = 0;
8302 94 tempitem.misc8 = 0;
8303 94 tempitem.misc9 = 0;
8304 94 tempitem.misc10 = 0;
8305 94 tempitem.wpn = 0;
8306 94 tempitem.wpn2 = 0;
8307 94 tempitem.wpn3 = 0;
8308 94 tempitem.wpn4 = 0;
8309 94 tempitem.wpn5 = 0;
8310 94 tempitem.wpn6 = 0;
8311 94 tempitem.wpn7 = 0;
8312 94 tempitem.wpn8 = 0;
8313 94 tempitem.wpn9 = 0;
8314 94 tempitem.wpn10 = 0;
8315 94 break;
8316 }
8317 case itype_hookshot:
8318 {
8319 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8320 184 tempitem.misc5 = 0;
8321 184 tempitem.misc6 = 0;
8322 184 tempitem.misc7 = 0;
8323 184 tempitem.misc8 = 0;
8324 184 tempitem.misc9 = 0;
8325 184 tempitem.misc10 = 0;
8326 184 tempitem.wpn5 = 0;
8327 184 tempitem.wpn6 = 0;
8328 184 tempitem.wpn7 = 0;
8329 184 tempitem.wpn8 = 0;
8330 184 tempitem.wpn9 = 0;
8331 184 tempitem.wpn10 = 0;
8332 184 break;
8333 }
8334 case itype_lens:
8335 {
8336 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8337 92 tempitem.misc2 = 0;
8338 92 tempitem.misc3 = 0;
8339 92 tempitem.misc4 = 0;
8340 92 tempitem.misc5 = 0;
8341 92 tempitem.misc6 = 0;
8342 92 tempitem.misc7 = 0;
8343 92 tempitem.misc8 = 0;
8344 92 tempitem.misc9 = 0;
8345 92 tempitem.misc10 = 0;
8346 92 tempitem.wpn = 0;
8347 92 tempitem.wpn2 = 0;
8348 92 tempitem.wpn3 = 0;
8349 92 tempitem.wpn4 = 0;
8350 92 tempitem.wpn5 = 0;
8351 92 tempitem.wpn6 = 0;
8352 92 tempitem.wpn7 = 0;
8353 92 tempitem.wpn8 = 0;
8354 92 tempitem.wpn9 = 0;
8355 92 tempitem.wpn10 = 0;
8356 92 break;
8357 }
8358 case itype_hammer:
8359 {
8360 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8361 93 tempitem.misc1 = 0;
8362 93 tempitem.misc2 = 0;
8363 93 tempitem.misc3 = 0;
8364 93 tempitem.misc4 = 0;
8365 93 tempitem.misc5 = 0;
8366 93 tempitem.misc6 = 0;
8367 93 tempitem.misc7 = 0;
8368 93 tempitem.misc8 = 0;
8369 93 tempitem.misc9 = 0;
8370 93 tempitem.misc10 = 0;
8371 93 tempitem.wpn3 = 0;
8372 93 tempitem.wpn4 = 0;
8373 93 tempitem.wpn5 = 0;
8374 93 tempitem.wpn6 = 0;
8375 93 tempitem.wpn7 = 0;
8376 93 tempitem.wpn8 = 0;
8377 93 tempitem.wpn9 = 0;
8378 93 tempitem.wpn10 = 0;
8379 93 break;
8380 }
8381 case itype_divinefire:
8382 {
8383 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG4 | ITEM_FLAG5);
8384 92 tempitem.misc3 = 0;
8385 92 tempitem.misc4 = 0;
8386 92 tempitem.misc5 = 0;
8387 92 tempitem.misc6 = 0;
8388 92 tempitem.misc7 = 0;
8389 92 tempitem.misc8 = 0;
8390 92 tempitem.misc9 = 0;
8391 92 tempitem.misc10 = 0;
8392 92 tempitem.wpn6 = 0;
8393 92 tempitem.wpn7 = 0;
8394 92 tempitem.wpn8 = 0;
8395 92 tempitem.wpn9 = 0;
8396 92 tempitem.wpn10 = 0;
8397 92 break;
8398 }
8399 case itype_divineescape:
8400 {
8401 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8402 92 tempitem.misc2 = 0;
8403 92 tempitem.misc3 = 0;
8404 92 tempitem.misc4 = 0;
8405 92 tempitem.misc5 = 0;
8406 92 tempitem.misc6 = 0;
8407 92 tempitem.misc7 = 0;
8408 92 tempitem.misc8 = 0;
8409 92 tempitem.misc9 = 0;
8410 92 tempitem.misc10 = 0;
8411 92 tempitem.wpn = 0;
8412 92 tempitem.wpn2 = 0;
8413 92 tempitem.wpn3 = 0;
8414 92 tempitem.wpn4 = 0;
8415 92 tempitem.wpn5 = 0;
8416 92 tempitem.wpn6 = 0;
8417 92 tempitem.wpn7 = 0;
8418 92 tempitem.wpn8 = 0;
8419 92 tempitem.wpn9 = 0;
8420 92 tempitem.wpn10 = 0;
8421 92 break;
8422 }
8423 case itype_divineprotection:
8424 {
8425 92 tempitem.flags &= ~ (ITEM_FLAG5);
8426 92 tempitem.misc2 = 0;
8427 92 tempitem.misc3 = 0;
8428 92 tempitem.misc4 = 0;
8429 92 tempitem.misc5 = 0;
8430 92 tempitem.misc6 = 0;
8431 92 tempitem.misc7 = 0;
8432 92 tempitem.misc8 = 0;
8433 92 tempitem.misc9 = 0;
8434 92 tempitem.misc10 = 0;
8435 92 break;
8436 }
8437 case itype_bomb:
8438 {
8439 107 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8440 107 tempitem.misc4 = 0;
8441 107 tempitem.misc5 = 0;
8442 107 tempitem.misc6 = 0;
8443 107 tempitem.misc7 = 0;
8444 107 tempitem.misc8 = 0;
8445 107 tempitem.misc9 = 0;
8446 107 tempitem.misc10 = 0;
8447 107 tempitem.wpn3 = 0;
8448 107 tempitem.wpn4 = 0;
8449 107 tempitem.wpn5 = 0;
8450 107 tempitem.wpn6 = 0;
8451 107 tempitem.wpn7 = 0;
8452 107 tempitem.wpn8 = 0;
8453 107 tempitem.wpn9 = 0;
8454 107 tempitem.wpn10 = 0;
8455 107 break;
8456 }
8457 case itype_sbomb:
8458 {
8459 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8460 92 tempitem.misc4 = 0;
8461 92 tempitem.misc5 = 0;
8462 92 tempitem.misc6 = 0;
8463 92 tempitem.misc7 = 0;
8464 92 tempitem.misc8 = 0;
8465 92 tempitem.misc9 = 0;
8466 92 tempitem.misc10 = 0;
8467 92 tempitem.wpn3 = 0;
8468 92 tempitem.wpn4 = 0;
8469 92 tempitem.wpn5 = 0;
8470 92 tempitem.wpn6 = 0;
8471 92 tempitem.wpn7 = 0;
8472 92 tempitem.wpn8 = 0;
8473 92 tempitem.wpn9 = 0;
8474 92 tempitem.wpn10 = 0;
8475 92 break;
8476 }
8477 case itype_clock:
8478 {
8479 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8480 93 tempitem.misc2 = 0;
8481 93 tempitem.misc3 = 0;
8482 93 tempitem.misc4 = 0;
8483 93 tempitem.misc5 = 0;
8484 93 tempitem.misc6 = 0;
8485 93 tempitem.misc7 = 0;
8486 93 tempitem.misc8 = 0;
8487 93 tempitem.misc9 = 0;
8488 93 tempitem.misc10 = 0;
8489 93 tempitem.wpn = 0;
8490 93 tempitem.wpn2 = 0;
8491 93 tempitem.wpn3 = 0;
8492 93 tempitem.wpn4 = 0;
8493 93 tempitem.wpn5 = 0;
8494 93 tempitem.wpn6 = 0;
8495 93 tempitem.wpn7 = 0;
8496 93 tempitem.wpn8 = 0;
8497 93 tempitem.wpn9 = 0;
8498 93 tempitem.wpn10 = 0;
8499 93 break;
8500 }
8501 case itype_key:
8502 {
8503 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8504 92 tempitem.misc1 = 0;
8505 92 tempitem.misc2 = 0;
8506 92 tempitem.misc3 = 0;
8507 92 tempitem.misc4 = 0;
8508 92 tempitem.misc5 = 0;
8509 92 tempitem.misc6 = 0;
8510 92 tempitem.misc7 = 0;
8511 92 tempitem.misc8 = 0;
8512 92 tempitem.misc9 = 0;
8513 92 tempitem.misc10 = 0;
8514 92 tempitem.wpn = 0;
8515 92 tempitem.wpn2 = 0;
8516 92 tempitem.wpn3 = 0;
8517 92 tempitem.wpn4 = 0;
8518 92 tempitem.wpn5 = 0;
8519 92 tempitem.wpn6 = 0;
8520 92 tempitem.wpn7 = 0;
8521 92 tempitem.wpn8 = 0;
8522 92 tempitem.wpn9 = 0;
8523 92 tempitem.wpn10 = 0;
8524 92 break;
8525 }
8526 case itype_magiccontainer:
8527 {
8528 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8529 93 tempitem.misc1 = 0;
8530 93 tempitem.misc2 = 0;
8531 93 tempitem.misc3 = 0;
8532 93 tempitem.misc4 = 0;
8533 93 tempitem.misc5 = 0;
8534 93 tempitem.misc6 = 0;
8535 93 tempitem.misc7 = 0;
8536 93 tempitem.misc8 = 0;
8537 93 tempitem.misc9 = 0;
8538 93 tempitem.misc10 = 0;
8539 93 tempitem.wpn = 0;
8540 93 tempitem.wpn2 = 0;
8541 93 tempitem.wpn3 = 0;
8542 93 tempitem.wpn4 = 0;
8543 93 tempitem.wpn5 = 0;
8544 93 tempitem.wpn6 = 0;
8545 93 tempitem.wpn7 = 0;
8546 93 tempitem.wpn8 = 0;
8547 93 tempitem.wpn9 = 0;
8548 93 tempitem.wpn10 = 0;
8549 93 break;
8550 }
8551 case itype_triforcepiece:
8552 {
8553 184 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8554 184 tempitem.misc3 = 0;
8555 184 tempitem.misc4 = 0;
8556 184 tempitem.misc5 = 0;
8557 184 tempitem.misc6 = 0;
8558 184 tempitem.misc7 = 0;
8559 184 tempitem.misc8 = 0;
8560 184 tempitem.misc9 = 0;
8561 184 tempitem.misc10 = 0;
8562 184 tempitem.wpn = 0;
8563 184 tempitem.wpn2 = 0;
8564 184 tempitem.wpn3 = 0;
8565 184 tempitem.wpn4 = 0;
8566 184 tempitem.wpn5 = 0;
8567 184 tempitem.wpn6 = 0;
8568 184 tempitem.wpn7 = 0;
8569 184 tempitem.wpn8 = 0;
8570 184 tempitem.wpn9 = 0;
8571 184 tempitem.wpn10 = 0;
8572 184 break;
8573 }
8574 case itype_map: case itype_compass: case itype_bosskey:
8575 {
8576 277 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8577 277 tempitem.misc1 = 0;
8578 277 tempitem.misc2 = 0;
8579 277 tempitem.misc3 = 0;
8580 277 tempitem.misc4 = 0;
8581 277 tempitem.misc5 = 0;
8582 277 tempitem.misc6 = 0;
8583 277 tempitem.misc7 = 0;
8584 277 tempitem.misc8 = 0;
8585 277 tempitem.misc9 = 0;
8586 277 tempitem.misc10 = 0;
8587 277 tempitem.wpn = 0;
8588 277 tempitem.wpn2 = 0;
8589 277 tempitem.wpn3 = 0;
8590 277 tempitem.wpn4 = 0;
8591 277 tempitem.wpn5 = 0;
8592 277 tempitem.wpn6 = 0;
8593 277 tempitem.wpn7 = 0;
8594 277 tempitem.wpn8 = 0;
8595 277 tempitem.wpn9 = 0;
8596 277 tempitem.wpn10 = 0;
8597 277 break;
8598 }
8599 case itype_quiver:
8600 {
8601 368 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8602 368 tempitem.misc3 = 0;
8603 368 tempitem.misc4 = 0;
8604 368 tempitem.misc5 = 0;
8605 368 tempitem.misc6 = 0;
8606 368 tempitem.misc7 = 0;
8607 368 tempitem.misc8 = 0;
8608 368 tempitem.misc9 = 0;
8609 368 tempitem.misc10 = 0;
8610 368 tempitem.wpn = 0;
8611 368 tempitem.wpn2 = 0;
8612 368 tempitem.wpn3 = 0;
8613 368 tempitem.wpn4 = 0;
8614 368 tempitem.wpn5 = 0;
8615 368 tempitem.wpn6 = 0;
8616 368 tempitem.wpn7 = 0;
8617 368 tempitem.wpn8 = 0;
8618 368 tempitem.wpn9 = 0;
8619 368 tempitem.wpn10 = 0;
8620 368 break;
8621 }
8622 case itype_lkey:
8623 {
8624 94 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8625 94 tempitem.misc1 = 0;
8626 94 tempitem.misc2 = 0;
8627 94 tempitem.misc3 = 0;
8628 94 tempitem.misc4 = 0;
8629 94 tempitem.misc5 = 0;
8630 94 tempitem.misc6 = 0;
8631 94 tempitem.misc7 = 0;
8632 94 tempitem.misc8 = 0;
8633 94 tempitem.misc9 = 0;
8634 94 tempitem.misc10 = 0;
8635 94 tempitem.wpn = 0;
8636 94 tempitem.wpn2 = 0;
8637 94 tempitem.wpn3 = 0;
8638 94 tempitem.wpn4 = 0;
8639 94 tempitem.wpn5 = 0;
8640 94 tempitem.wpn6 = 0;
8641 94 tempitem.wpn7 = 0;
8642 94 tempitem.wpn8 = 0;
8643 94 tempitem.wpn9 = 0;
8644 94 tempitem.wpn10 = 0;
8645 94 break;
8646 }
8647 case itype_cbyrna:
8648 {
8649 92 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG5);
8650 92 tempitem.misc4 = 0;
8651 92 tempitem.misc5 = 0;
8652 92 tempitem.misc6 = 0;
8653 92 tempitem.misc7 = 0;
8654 92 tempitem.misc8 = 0;
8655 92 tempitem.misc9 = 0;
8656 92 tempitem.misc10 = 0;
8657 92 tempitem.wpn6 = 0;
8658 92 tempitem.wpn7 = 0;
8659 92 tempitem.wpn8 = 0;
8660 92 tempitem.wpn9 = 0;
8661 92 tempitem.wpn10 = 0;
8662 92 break;
8663 }
8664 case itype_rupee: case itype_arrowammo:
8665 {
8666 1135 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8667 1135 tempitem.misc1 = 0;
8668 1135 tempitem.misc2 = 0;
8669 1135 tempitem.misc3 = 0;
8670 1135 tempitem.misc4 = 0;
8671 1135 tempitem.misc5 = 0;
8672 1135 tempitem.misc6 = 0;
8673 1135 tempitem.misc7 = 0;
8674 1135 tempitem.misc8 = 0;
8675 1135 tempitem.misc9 = 0;
8676 1135 tempitem.misc10 = 0;
8677 1135 tempitem.wpn = 0;
8678 1135 tempitem.wpn2 = 0;
8679 1135 tempitem.wpn3 = 0;
8680 1135 tempitem.wpn4 = 0;
8681 1135 tempitem.wpn5 = 0;
8682 1135 tempitem.wpn6 = 0;
8683 1135 tempitem.wpn7 = 0;
8684 1135 tempitem.wpn8 = 0;
8685 1135 tempitem.wpn9 = 0;
8686 1135 tempitem.wpn10 = 0;
8687 1135 break;
8688 }
8689 case itype_fairy:
8690 {
8691 168 tempitem.flags &= ~ (ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8692 168 tempitem.misc4 = 0;
8693 168 tempitem.misc5 = 0;
8694 168 tempitem.misc6 = 0;
8695 168 tempitem.misc7 = 0;
8696 168 tempitem.misc8 = 0;
8697 168 tempitem.misc9 = 0;
8698 168 tempitem.misc10 = 0;
8699 168 tempitem.wpn = 0;
8700 168 tempitem.wpn2 = 0;
8701 168 tempitem.wpn3 = 0;
8702 168 tempitem.wpn4 = 0;
8703 168 tempitem.wpn5 = 0;
8704 168 tempitem.wpn6 = 0;
8705 168 tempitem.wpn7 = 0;
8706 168 tempitem.wpn8 = 0;
8707 168 tempitem.wpn9 = 0;
8708 168 tempitem.wpn10 = 0;
8709 168 break;
8710 }
8711 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8712 {
8713 983 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8714 983 tempitem.misc1 = 0;
8715 983 tempitem.misc2 = 0;
8716 983 tempitem.misc3 = 0;
8717 983 tempitem.misc4 = 0;
8718 983 tempitem.misc5 = 0;
8719 983 tempitem.misc6 = 0;
8720 983 tempitem.misc7 = 0;
8721 983 tempitem.misc8 = 0;
8722 983 tempitem.misc9 = 0;
8723 983 tempitem.misc10 = 0;
8724 983 tempitem.wpn = 0;
8725 983 tempitem.wpn2 = 0;
8726 983 tempitem.wpn3 = 0;
8727 983 tempitem.wpn4 = 0;
8728 983 tempitem.wpn5 = 0;
8729 983 tempitem.wpn6 = 0;
8730 983 tempitem.wpn7 = 0;
8731 983 tempitem.wpn8 = 0;
8732 983 tempitem.wpn9 = 0;
8733 983 tempitem.wpn10 = 0;
8734 983 break;
8735 }
8736 case itype_bombbag:
8737 {
8738 368 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8739 368 tempitem.misc3 = 0;
8740 368 tempitem.misc4 = 0;
8741 368 tempitem.misc5 = 0;
8742 368 tempitem.misc6 = 0;
8743 368 tempitem.misc7 = 0;
8744 368 tempitem.misc8 = 0;
8745 368 tempitem.misc9 = 0;
8746 368 tempitem.misc10 = 0;
8747 368 tempitem.wpn = 0;
8748 368 tempitem.wpn2 = 0;
8749 368 tempitem.wpn3 = 0;
8750 368 tempitem.wpn4 = 0;
8751 368 tempitem.wpn5 = 0;
8752 368 tempitem.wpn6 = 0;
8753 368 tempitem.wpn7 = 0;
8754 368 tempitem.wpn8 = 0;
8755 368 tempitem.wpn9 = 0;
8756 368 tempitem.wpn10 = 0;
8757 368 break;
8758 }
8759 case itype_rocs:
8760 {
8761 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8762 92 tempitem.misc1 = 0;
8763 92 tempitem.misc2 = 0;
8764 92 tempitem.misc3 = 0;
8765 92 tempitem.misc4 = 0;
8766 92 tempitem.misc5 = 0;
8767 92 tempitem.misc6 = 0;
8768 92 tempitem.misc7 = 0;
8769 92 tempitem.misc8 = 0;
8770 92 tempitem.misc9 = 0;
8771 92 tempitem.misc10 = 0;
8772 92 tempitem.wpn = 0;
8773 92 tempitem.wpn2 = 0;
8774 92 tempitem.wpn3 = 0;
8775 92 tempitem.wpn4 = 0;
8776 92 tempitem.wpn5 = 0;
8777 92 tempitem.wpn6 = 0;
8778 92 tempitem.wpn7 = 0;
8779 92 tempitem.wpn8 = 0;
8780 92 tempitem.wpn9 = 0;
8781 92 tempitem.wpn10 = 0;
8782 92 break;
8783 }
8784 case itype_hoverboots:
8785 {
8786 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8787 92 tempitem.misc2 = 0;
8788 92 tempitem.misc3 = 0;
8789 92 tempitem.misc4 = 0;
8790 92 tempitem.misc5 = 0;
8791 92 tempitem.misc6 = 0;
8792 92 tempitem.misc7 = 0;
8793 92 tempitem.misc8 = 0;
8794 92 tempitem.misc9 = 0;
8795 92 tempitem.misc10 = 0;
8796 92 tempitem.wpn2 = 0;
8797 92 tempitem.wpn3 = 0;
8798 92 tempitem.wpn4 = 0;
8799 92 tempitem.wpn5 = 0;
8800 92 tempitem.wpn6 = 0;
8801 92 tempitem.wpn7 = 0;
8802 92 tempitem.wpn8 = 0;
8803 92 tempitem.wpn9 = 0;
8804 92 tempitem.wpn10 = 0;
8805 92 break;
8806 }
8807 case itype_spinscroll:
8808 {
8809 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8810 92 tempitem.misc2 = 0;
8811 92 tempitem.misc3 = 0;
8812 92 tempitem.misc4 = 0;
8813 92 tempitem.misc5 = 0;
8814 92 tempitem.misc6 = 0;
8815 92 tempitem.misc7 = 0;
8816 92 tempitem.misc8 = 0;
8817 92 tempitem.misc9 = 0;
8818 92 tempitem.misc10 = 0;
8819 92 tempitem.wpn = 0;
8820 92 tempitem.wpn2 = 0;
8821 92 tempitem.wpn3 = 0;
8822 92 tempitem.wpn4 = 0;
8823 92 tempitem.wpn5 = 0;
8824 92 tempitem.wpn6 = 0;
8825 92 tempitem.wpn7 = 0;
8826 92 tempitem.wpn8 = 0;
8827 92 tempitem.wpn9 = 0;
8828 92 tempitem.wpn10 = 0;
8829 92 break;
8830 }
8831 case itype_crossscroll:
8832 {
8833 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8834 92 tempitem.misc1 = 0;
8835 92 tempitem.misc2 = 0;
8836 92 tempitem.misc3 = 0;
8837 92 tempitem.misc4 = 0;
8838 92 tempitem.misc5 = 0;
8839 92 tempitem.misc6 = 0;
8840 92 tempitem.misc7 = 0;
8841 92 tempitem.misc8 = 0;
8842 92 tempitem.misc9 = 0;
8843 92 tempitem.misc10 = 0;
8844 92 tempitem.wpn = 0;
8845 92 tempitem.wpn2 = 0;
8846 92 tempitem.wpn3 = 0;
8847 92 tempitem.wpn4 = 0;
8848 92 tempitem.wpn5 = 0;
8849 92 tempitem.wpn6 = 0;
8850 92 tempitem.wpn7 = 0;
8851 92 tempitem.wpn8 = 0;
8852 92 tempitem.wpn9 = 0;
8853 92 tempitem.wpn10 = 0;
8854 92 break;
8855 }
8856 case itype_quakescroll:
8857 {
8858 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8859 92 tempitem.misc3 = 0;
8860 92 tempitem.misc4 = 0;
8861 92 tempitem.misc5 = 0;
8862 92 tempitem.misc6 = 0;
8863 92 tempitem.misc7 = 0;
8864 92 tempitem.misc8 = 0;
8865 92 tempitem.misc9 = 0;
8866 92 tempitem.misc10 = 0;
8867 92 tempitem.wpn = 0;
8868 92 tempitem.wpn2 = 0;
8869 92 tempitem.wpn3 = 0;
8870 92 tempitem.wpn4 = 0;
8871 92 tempitem.wpn5 = 0;
8872 92 tempitem.wpn6 = 0;
8873 92 tempitem.wpn7 = 0;
8874 92 tempitem.wpn8 = 0;
8875 92 tempitem.wpn9 = 0;
8876 92 tempitem.wpn10 = 0;
8877 92 break;
8878 }
8879 case itype_whispring:
8880 {
8881 185 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8882 185 tempitem.misc2 = 0;
8883 185 tempitem.misc3 = 0;
8884 185 tempitem.misc4 = 0;
8885 185 tempitem.misc5 = 0;
8886 185 tempitem.misc6 = 0;
8887 185 tempitem.misc7 = 0;
8888 185 tempitem.misc8 = 0;
8889 185 tempitem.misc9 = 0;
8890 185 tempitem.misc10 = 0;
8891 185 tempitem.wpn = 0;
8892 185 tempitem.wpn2 = 0;
8893 185 tempitem.wpn3 = 0;
8894 185 tempitem.wpn4 = 0;
8895 185 tempitem.wpn5 = 0;
8896 185 tempitem.wpn6 = 0;
8897 185 tempitem.wpn7 = 0;
8898 185 tempitem.wpn8 = 0;
8899 185 tempitem.wpn9 = 0;
8900 185 tempitem.wpn10 = 0;
8901 185 break;
8902 }
8903 case itype_chargering:
8904 {
8905 184 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8906 184 tempitem.misc3 = 0;
8907 184 tempitem.misc4 = 0;
8908 184 tempitem.misc5 = 0;
8909 184 tempitem.misc6 = 0;
8910 184 tempitem.misc7 = 0;
8911 184 tempitem.misc8 = 0;
8912 184 tempitem.misc9 = 0;
8913 184 tempitem.misc10 = 0;
8914 184 tempitem.wpn = 0;
8915 184 tempitem.wpn2 = 0;
8916 184 tempitem.wpn3 = 0;
8917 184 tempitem.wpn4 = 0;
8918 184 tempitem.wpn5 = 0;
8919 184 tempitem.wpn6 = 0;
8920 184 tempitem.wpn7 = 0;
8921 184 tempitem.wpn8 = 0;
8922 184 tempitem.wpn9 = 0;
8923 184 tempitem.wpn10 = 0;
8924 184 break;
8925 }
8926 case itype_perilscroll:
8927 {
8928 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8929 92 tempitem.misc2 = 0;
8930 92 tempitem.misc3 = 0;
8931 92 tempitem.misc4 = 0;
8932 92 tempitem.misc5 = 0;
8933 92 tempitem.misc6 = 0;
8934 92 tempitem.misc7 = 0;
8935 92 tempitem.misc8 = 0;
8936 92 tempitem.misc9 = 0;
8937 92 tempitem.misc10 = 0;
8938 92 tempitem.wpn = 0;
8939 92 tempitem.wpn2 = 0;
8940 92 tempitem.wpn3 = 0;
8941 92 tempitem.wpn4 = 0;
8942 92 tempitem.wpn5 = 0;
8943 92 tempitem.wpn6 = 0;
8944 92 tempitem.wpn7 = 0;
8945 92 tempitem.wpn8 = 0;
8946 92 tempitem.wpn9 = 0;
8947 92 tempitem.wpn10 = 0;
8948 92 break;
8949 }
8950 case itype_wealthmedal:
8951 {
8952 277 tempitem.flags &= ~ (ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8953 277 tempitem.misc2 = 0;
8954 277 tempitem.misc3 = 0;
8955 277 tempitem.misc4 = 0;
8956 277 tempitem.misc5 = 0;
8957 277 tempitem.misc6 = 0;
8958 277 tempitem.misc7 = 0;
8959 277 tempitem.misc8 = 0;
8960 277 tempitem.misc9 = 0;
8961 277 tempitem.misc10 = 0;
8962 277 tempitem.wpn = 0;
8963 277 tempitem.wpn2 = 0;
8964 277 tempitem.wpn3 = 0;
8965 277 tempitem.wpn4 = 0;
8966 277 tempitem.wpn5 = 0;
8967 277 tempitem.wpn6 = 0;
8968 277 tempitem.wpn7 = 0;
8969 277 tempitem.wpn8 = 0;
8970 277 tempitem.wpn9 = 0;
8971 277 tempitem.wpn10 = 0;
8972 277 break;
8973 }
8974 case itype_heartring:
8975 {
8976 278 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
8977 278 tempitem.misc3 = 0;
8978 278 tempitem.misc4 = 0;
8979 278 tempitem.misc5 = 0;
8980 278 tempitem.misc6 = 0;
8981 278 tempitem.misc7 = 0;
8982 278 tempitem.misc8 = 0;
8983 278 tempitem.misc9 = 0;
8984 278 tempitem.misc10 = 0;
8985 278 tempitem.wpn = 0;
8986 278 tempitem.wpn2 = 0;
8987 278 tempitem.wpn3 = 0;
8988 278 tempitem.wpn4 = 0;
8989 278 tempitem.wpn5 = 0;
8990 278 tempitem.wpn6 = 0;
8991 278 tempitem.wpn7 = 0;
8992 278 tempitem.wpn8 = 0;
8993 278 tempitem.wpn9 = 0;
8994 278 tempitem.wpn10 = 0;
8995 278 break;
8996 }
8997 case itype_magicring:
8998 {
8999 372 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9000 372 tempitem.misc3 = 0;
9001 372 tempitem.misc4 = 0;
9002 372 tempitem.misc5 = 0;
9003 372 tempitem.misc6 = 0;
9004 372 tempitem.misc7 = 0;
9005 372 tempitem.misc8 = 0;
9006 372 tempitem.misc9 = 0;
9007 372 tempitem.misc10 = 0;
9008 372 tempitem.wpn = 0;
9009 372 tempitem.wpn2 = 0;
9010 372 tempitem.wpn3 = 0;
9011 372 tempitem.wpn4 = 0;
9012 372 tempitem.wpn5 = 0;
9013 372 tempitem.wpn6 = 0;
9014 372 tempitem.wpn7 = 0;
9015 372 tempitem.wpn8 = 0;
9016 372 tempitem.wpn9 = 0;
9017 372 tempitem.wpn10 = 0;
9018 372 break;
9019 }
9020 case itype_spinscroll2:
9021 {
9022 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9023 92 tempitem.misc2 = 0;
9024 92 tempitem.misc3 = 0;
9025 92 tempitem.misc4 = 0;
9026 92 tempitem.misc5 = 0;
9027 92 tempitem.misc6 = 0;
9028 92 tempitem.misc7 = 0;
9029 92 tempitem.misc8 = 0;
9030 92 tempitem.misc9 = 0;
9031 92 tempitem.misc10 = 0;
9032 92 tempitem.wpn = 0;
9033 92 tempitem.wpn2 = 0;
9034 92 tempitem.wpn3 = 0;
9035 92 tempitem.wpn4 = 0;
9036 92 tempitem.wpn5 = 0;
9037 92 tempitem.wpn6 = 0;
9038 92 tempitem.wpn7 = 0;
9039 92 tempitem.wpn8 = 0;
9040 92 tempitem.wpn9 = 0;
9041 92 tempitem.wpn10 = 0;
9042 92 break;
9043 }
9044 case itype_quakescroll2:
9045 {
9046 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9047 92 tempitem.misc3 = 0;
9048 92 tempitem.misc4 = 0;
9049 92 tempitem.misc5 = 0;
9050 92 tempitem.misc6 = 0;
9051 92 tempitem.misc7 = 0;
9052 92 tempitem.misc8 = 0;
9053 92 tempitem.misc9 = 0;
9054 92 tempitem.misc10 = 0;
9055 92 tempitem.wpn = 0;
9056 92 tempitem.wpn2 = 0;
9057 92 tempitem.wpn3 = 0;
9058 92 tempitem.wpn4 = 0;
9059 92 tempitem.wpn5 = 0;
9060 92 tempitem.wpn6 = 0;
9061 92 tempitem.wpn7 = 0;
9062 92 tempitem.wpn8 = 0;
9063 92 tempitem.wpn9 = 0;
9064 92 tempitem.wpn10 = 0;
9065 92 break;
9066 }
9067 case itype_agony:
9068 {
9069 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9070 92 tempitem.misc2 = 0;
9071 92 tempitem.misc3 = 0;
9072 92 tempitem.misc4 = 0;
9073 92 tempitem.misc5 = 0;
9074 92 tempitem.misc6 = 0;
9075 92 tempitem.misc7 = 0;
9076 92 tempitem.misc8 = 0;
9077 92 tempitem.misc9 = 0;
9078 92 tempitem.misc10 = 0;
9079 92 tempitem.wpn = 0;
9080 92 tempitem.wpn2 = 0;
9081 92 tempitem.wpn3 = 0;
9082 92 tempitem.wpn4 = 0;
9083 92 tempitem.wpn5 = 0;
9084 92 tempitem.wpn6 = 0;
9085 92 tempitem.wpn7 = 0;
9086 92 tempitem.wpn8 = 0;
9087 92 tempitem.wpn9 = 0;
9088 92 tempitem.wpn10 = 0;
9089 92 break;
9090 }
9091 case itype_stompboots:
9092 {
9093 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9094 92 tempitem.misc1 = 0;
9095 92 tempitem.misc2 = 0;
9096 92 tempitem.misc3 = 0;
9097 92 tempitem.misc4 = 0;
9098 92 tempitem.misc5 = 0;
9099 92 tempitem.misc6 = 0;
9100 92 tempitem.misc7 = 0;
9101 92 tempitem.misc8 = 0;
9102 92 tempitem.misc9 = 0;
9103 92 tempitem.misc10 = 0;
9104 92 tempitem.wpn = 0;
9105 92 tempitem.wpn2 = 0;
9106 92 tempitem.wpn3 = 0;
9107 92 tempitem.wpn4 = 0;
9108 92 tempitem.wpn5 = 0;
9109 92 tempitem.wpn6 = 0;
9110 92 tempitem.wpn7 = 0;
9111 92 tempitem.wpn8 = 0;
9112 92 tempitem.wpn9 = 0;
9113 92 tempitem.wpn10 = 0;
9114 92 break;
9115 }
9116 case itype_whimsicalring:
9117 {
9118 92 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9119 92 tempitem.misc2 = 0;
9120 92 tempitem.misc3 = 0;
9121 92 tempitem.misc4 = 0;
9122 92 tempitem.misc5 = 0;
9123 92 tempitem.misc6 = 0;
9124 92 tempitem.misc7 = 0;
9125 92 tempitem.misc8 = 0;
9126 92 tempitem.misc9 = 0;
9127 92 tempitem.misc10 = 0;
9128 92 tempitem.wpn = 0;
9129 92 tempitem.wpn2 = 0;
9130 92 tempitem.wpn3 = 0;
9131 92 tempitem.wpn4 = 0;
9132 92 tempitem.wpn5 = 0;
9133 92 tempitem.wpn6 = 0;
9134 92 tempitem.wpn7 = 0;
9135 92 tempitem.wpn8 = 0;
9136 92 tempitem.wpn9 = 0;
9137 92 tempitem.wpn10 = 0;
9138 92 break;
9139 }
9140 case itype_perilring:
9141 {
9142 93 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9143 93 tempitem.misc2 = 0;
9144 93 tempitem.misc3 = 0;
9145 93 tempitem.misc4 = 0;
9146 93 tempitem.misc5 = 0;
9147 93 tempitem.misc6 = 0;
9148 93 tempitem.misc7 = 0;
9149 93 tempitem.misc8 = 0;
9150 93 tempitem.misc9 = 0;
9151 93 tempitem.misc10 = 0;
9152 93 tempitem.wpn = 0;
9153 93 tempitem.wpn2 = 0;
9154 93 tempitem.wpn3 = 0;
9155 93 tempitem.wpn4 = 0;
9156 93 tempitem.wpn5 = 0;
9157 93 tempitem.wpn6 = 0;
9158 93 tempitem.wpn7 = 0;
9159 93 tempitem.wpn8 = 0;
9160 93 tempitem.wpn9 = 0;
9161 93 tempitem.wpn10 = 0;
9162 93 break;
9163 }
9164 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9165 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9166 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9167 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9168 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9169 {
9170 2541 tempitem.flags &= ~ (ITEM_FLAG1 | ITEM_FLAG2 | ITEM_FLAG3 | ITEM_FLAG4 | ITEM_FLAG5);
9171 2541 tempitem.misc1 = 0;
9172 2541 tempitem.misc2 = 0;
9173 2541 tempitem.misc3 = 0;
9174 2541 tempitem.misc4 = 0;
9175 2541 tempitem.misc5 = 0;
9176 2541 tempitem.misc6 = 0;
9177 2541 tempitem.misc7 = 0;
9178 2541 tempitem.misc8 = 0;
9179 2541 tempitem.misc9 = 0;
9180 2541 tempitem.misc10 = 0;
9181 2541 tempitem.wpn = 0;
9182 2541 tempitem.wpn2 = 0;
9183 2541 tempitem.wpn3 = 0;
9184 2541 tempitem.wpn4 = 0;
9185 2541 tempitem.wpn5 = 0;
9186 2541 tempitem.wpn6 = 0;
9187 2541 tempitem.wpn7 = 0;
9188 2541 tempitem.wpn8 = 0;
9189 2541 tempitem.wpn9 = 0;
9190 2541 tempitem.wpn10 = 0;
9191 2541 break;
9192 }
9193 }
9194 23808 }
9195 //Port quest rules to items
9196
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 31)
9197 {
9198
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_bomb)
9199 {
9200
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 90 times.
107 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9201 90 else tempitem.flags &= ~ ITEM_FLAG2;
9202 107 }
9203
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23609 times.
23701 else if(tempitem.family == itype_sbomb)
9204 {
9205
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 75 times.
92 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= ITEM_FLAG2;
9206 75 else tempitem.flags &= ~ ITEM_FLAG2;
9207 92 }
9208
9209
2/2
✓ Branch 0 taken 277 times.
✓ Branch 1 taken 23332 times.
23609 else if(tempitem.family == itype_brang)
9210 {
9211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= ITEM_FLAG4;
9212 277 else tempitem.flags &= ~ ITEM_FLAG4;
9213 277 }
9214
2/2
✓ Branch 0 taken 23225 times.
✓ Branch 1 taken 107 times.
23332 else if(tempitem.family == itype_wand)
9215 {
9216
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= ITEM_FLAG3;
9217 105 else tempitem.flags &= ~ ITEM_FLAG3;
9218 107 }
9219 23808 }
9220
9221 //Port quest rules to items
9222
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version <= 37)
9223 {
9224
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23715 times.
23808 if(tempitem.family == itype_flippers)
9225 {
9226
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93 times.
93 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= ITEM_FLAG1;
9227 93 else tempitem.flags &= ~ ITEM_FLAG1;
9228 93 }
9229
2/2
✓ Branch 0 taken 15904 times.
✓ Branch 1 taken 7811 times.
23715 else if(tempitem.family == itype_sword)
9230 {
9231
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9232 7742 else tempitem.flags &= ~ ITEM_FLAG5;
9233 7811 }
9234
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 15797 times.
15904 else if(tempitem.family == itype_wand)
9235 {
9236
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 104 times.
107 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= ITEM_FLAG5;
9237 104 else tempitem.flags &= ~ ITEM_FLAG5;
9238 107 }
9239
4/4
✓ Branch 0 taken 15690 times.
✓ Branch 1 taken 107 times.
✓ Branch 2 taken 222 times.
✓ Branch 3 taken 15468 times.
15797 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9240 {
9241 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9242
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 257 times.
329 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= ITEM_FLAG3;
9243 257 else tempitem.flags &= ~ ITEM_FLAG3;
9244 329 }
9245 23808 }
9246
9247
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 38)
9248 {
9249
4/4
✓ Branch 0 taken 23531 times.
✓ Branch 1 taken 277 times.
✓ Branch 2 taken 184 times.
✓ Branch 3 taken 23347 times.
23808 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9250 {
9251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 461 times.
461 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9252 461 else tempitem.flags &= ~ITEM_FLAG4;
9253
9254
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 450 times.
461 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= ITEM_FLAG5 | ITEM_FLAG6;
9255 450 else tempitem.flags &= ~(ITEM_FLAG5|ITEM_FLAG6);
9256 461 }
9257
2/2
✓ Branch 0 taken 23073 times.
✓ Branch 1 taken 274 times.
23347 else if(tempitem.family == itype_arrow)
9258 {
9259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 274 times.
274 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= ITEM_FLAG4;
9260 274 else tempitem.flags &= ~ITEM_FLAG4;
9261
9262
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 270 times.
274 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~ITEM_FLAG2;
9263 270 else tempitem.flags |= ITEM_FLAG2;
9264 274 }
9265 23808 }
9266
9267
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 39)
9268 {
9269
6/6
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
✓ Branch 2 taken 23609 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 222 times.
✓ Branch 5 taken 23387 times.
23808 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9270 {
9271
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 409 times.
421 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= ITEM_FLAG5;
9272 409 else tempitem.flags &= ~ITEM_FLAG5;
9273 421 }
9274
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 23204 times.
23387 else if(tempitem.family == itype_potion)
9275 {
9276
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 159 times.
183 if(get_qr(qr_NONBUBBLEMEDICINE))
9277 {
9278 24 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9279 24 }
9280 else
9281 {
9282 159 tempitem.flags |= ITEM_FLAG3;
9283
2/2
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 74 times.
159 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9284 74 else tempitem.flags &= ~ITEM_FLAG4;
9285 }
9286 183 }
9287
2/2
✓ Branch 0 taken 23020 times.
✓ Branch 1 taken 184 times.
23204 else if(tempitem.family == itype_triforcepiece)
9288 {
9289
2/2
✓ Branch 0 taken 30 times.
✓ Branch 1 taken 154 times.
184 if(get_qr(qr_NONBUBBLETRIFORCE))
9290 {
9291 30 tempitem.flags |= ITEM_FLAG3;
9292
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= ITEM_FLAG4;
9293 24 else tempitem.flags &= ~ITEM_FLAG4;
9294 30 }
9295 else
9296 {
9297 154 tempitem.flags &= ~(ITEM_FLAG3|ITEM_FLAG4);
9298 }
9299 184 }
9300 23808 }
9301
9302
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 40)
9303 {
9304
4/4
✓ Branch 0 taken 23506 times.
✓ Branch 1 taken 302 times.
✓ Branch 2 taken 93 times.
✓ Branch 3 taken 23413 times.
23808 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9305 {
9306
2/2
✓ Branch 0 taken 47 times.
✓ Branch 1 taken 348 times.
395 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= ITEM_FLAG1;
9307 348 else tempitem.flags &= ~ITEM_FLAG1;
9308 395 }
9309
8/8
✓ Branch 0 taken 23191 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 15380 times.
✓ Branch 3 taken 7811 times.
✓ Branch 4 taken 15273 times.
✓ Branch 5 taken 107 times.
✓ Branch 6 taken 92 times.
✓ Branch 7 taken 15181 times.
23413 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9310 {
9311
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 8151 times.
8232 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= ITEM_FLAG8;
9312 8151 else tempitem.flags &= ~ITEM_FLAG8;
9313 8232 }
9314
6/6
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
✓ Branch 2 taken 15890 times.
✓ Branch 3 taken 107 times.
✓ Branch 4 taken 93 times.
✓ Branch 5 taken 15797 times.
23808 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9315 {
9316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8011 times.
8011 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= ITEM_FLAG7;
9317 8011 else tempitem.flags &= ~ITEM_FLAG7;
9318 8011 }
9319
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 92 times.
15797 else if(tempitem.family == itype_cbyrna)
9320 {
9321 92 tempitem.flags |= ITEM_FLAG7;
9322 92 }
9323 23808 }
9324
9325
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 41 )
9326 {
9327
2/2
✓ Branch 0 taken 15997 times.
✓ Branch 1 taken 7811 times.
23808 if(tempitem.family == itype_sword)
9328 {
9329
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= ITEM_FLAG9;
9330 7742 else tempitem.flags &= ~ITEM_FLAG9;
9331
9332
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 7742 times.
7811 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= ITEM_FLAG10;
9333 7742 else tempitem.flags &= ~ITEM_FLAG10;
9334 7811 }
9335 23808 }
9336
9337
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 42 )
9338 {
9339
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23701 times.
23808 if(tempitem.family == itype_wand)
9340 {
9341
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 105 times.
107 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= ITEM_FLAG3;
9342 105 else tempitem.flags &= ~ITEM_FLAG3;
9343
9344 107 tempitem.flags &= ~ITEM_FLAG6;
9345 107 }
9346
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 23608 times.
23701 else if(tempitem.family == itype_hammer)
9347 {
9348 93 tempitem.flags &= ~ITEM_FLAG3;
9349 93 }
9350
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 23516 times.
23608 else if(tempitem.family == itype_cbyrna)
9351 {
9352 92 tempitem.flags |= ITEM_FLAG3;
9353
9354 92 tempitem.flags &= ~ITEM_FLAG6;
9355 92 }
9356
2/2
✓ Branch 0 taken 15705 times.
✓ Branch 1 taken 7811 times.
23516 else if(tempitem.family == itype_sword)
9357 {
9358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7811 times.
7811 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= ITEM_FLAG6;
9359 7811 else tempitem.flags &= ~ITEM_FLAG6;
9360 7811 }
9361 23808 }
9362
9363
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 43 )
9364 {
9365
2/2
✓ Branch 0 taken 23670 times.
✓ Branch 1 taken 138 times.
23808 if(tempitem.family == itype_whistle)
9366 {
9367
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 135 times.
138 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= ITEM_FLAG3;
9368 135 else tempitem.flags &= ~ITEM_FLAG3;
9369 138 }
9370 23808 }
9371
9372
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 45 )
9373 {
9374
2/2
✓ Branch 0 taken 23715 times.
✓ Branch 1 taken 93 times.
23808 if(tempitem.family == itype_flippers)
9375 {
9376 93 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9377 93 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9378 93 }
9379 23808 }
9380
9381
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 46 )
9382 {
9383
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if(tempitem.family == itype_raft)
9384 {
9385 92 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9386 92 }
9387 23808 }
9388
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 34 ) //! set the default counter for older quests.
9389 {
9390
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 23733 times.
23808 if ( (tempitem.flags & ITEM_RUPEE_MAGIC) )
9391 {
9392 75 tempitem.cost_counter[0] = 1;
9393 75 }
9394 else
9395 {
9396
2/2
✓ Branch 0 taken 4608 times.
✓ Branch 1 taken 19125 times.
23733 if(get_qr(qr_ENABLEMAGIC))
9397 4608 tempitem.cost_counter[0] = 4;
9398 else
9399 {
9400 19125 tempitem.cost_amount[0] = 0;
9401 19125 tempitem.cost_counter[0] = -1;
9402 }
9403 }
9404 23808 }
9405
9406
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 35 ) //new Lens of Truth flags
9407 {
9408
2/2
✓ Branch 0 taken 23716 times.
✓ Branch 1 taken 92 times.
23808 if ( tempitem.family == itype_lens )
9409 {
9410
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 3 times.
92 if ( get_qr(qr_RAFTLENS) )
9411 {
9412 3 tempitem.flags |= ITEM_FLAG4;
9413 3 }
9414
2/2
✓ Branch 0 taken 40 times.
✓ Branch 1 taken 52 times.
92 if ( get_qr(qr_LENSHINTS) )
9415 {
9416 52 tempitem.flags |= ITEM_FLAG1;
9417 52 }
9418
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 4 times.
92 if ( get_qr(qr_LENSSEESENEMIES) )
9419 {
9420 4 tempitem.flags |= ITEM_FLAG5;
9421 4 }
9422 92 }
9423 23808 }
9424
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9425 {
9426
2/2
✓ Branch 0 taken 190464 times.
✓ Branch 1 taken 23808 times.
214272 for ( int32_t q = 0; q < 8; q++ )
9427 {
9428 190464 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9429 190464 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9430 190464 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9431 190464 tempitem.sprite_initiald[q] = 0;
9432 190464 }
9433
2/2
✓ Branch 0 taken 47616 times.
✓ Branch 1 taken 23808 times.
71424 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9434 23808 tempitem.sprite_script = 0;
9435 23808 }
9436
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9437 {
9438 23808 tempitem.pickupflag = 0;
9439 23808 }
9440
9441
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 51 )
9442 {
9443
2/2
✓ Branch 0 taken 23586 times.
✓ Branch 1 taken 222 times.
23808 if( tempitem.family == itype_candle )
9444 {
9445 222 tempitem.misc4 = 50; //Step speed
9446 222 }
9447 23808 }
9448
9449
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if( s_version < 52 )
9450 {
9451
2/2
✓ Branch 0 taken 23525 times.
✓ Branch 1 taken 283 times.
23808 if( tempitem.family == itype_shield )
9452 283 tempitem.flags |= ITEM_FLAG1; //'Block Front' flag
9453 23808 }
9454
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 23808 times.
33024 if(s_version < 53)
9455 {
9456
4/4
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 23335 times.
✓ Branch 2 taken 274 times.
✓ Branch 3 taken 92 times.
23808 switch(tempitem.family)
9457 {
9458 case itype_arrow:
9459 274 tempitem.cost_counter[1] = crARROWS;
9460 274 tempitem.cost_amount[1] = 1;
9461 274 break;
9462 case itype_bomb:
9463 107 tempitem.cost_counter[1] = crBOMBS;
9464 107 tempitem.cost_amount[1] = 1;
9465 107 break;
9466 case itype_sbomb:
9467 92 tempitem.cost_counter[1] = crSBOMBS;
9468 92 tempitem.cost_amount[1] = 1;
9469 92 break;
9470 default:
9471 23335 tempitem.cost_counter[1] = crNONE;
9472 23335 tempitem.cost_amount[1] = 0;
9473 23335 }
9474 23808 tempitem.magiccosttimer[1] = 0;
9475 23808 }
9476
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if( s_version < 54 )
9477 {
9478
2/2
✓ Branch 0 taken 24989 times.
✓ Branch 1 taken 99 times.
25088 if( tempitem.family == itype_flippers )
9479 99 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9480 25088 }
9481
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 55)
9482 {
9483
3/3
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 194 times.
✓ Branch 2 taken 24700 times.
25088 switch(tempitem.family)
9484 {
9485 case itype_spinscroll:
9486 case itype_quakescroll:
9487 194 tempitem.usesound2 = WAV_ZN1CHARGE;
9488 194 break;
9489 case itype_spinscroll2:
9490 case itype_quakescroll2:
9491 194 tempitem.usesound2 = WAV_ZN1CHARGE2;
9492 194 break;
9493 }
9494 25088 }
9495
2/2
✓ Branch 0 taken 7936 times.
✓ Branch 1 taken 25088 times.
33024 if(s_version < 56)
9496 {
9497
4/4
✓ Branch 0 taken 24645 times.
✓ Branch 1 taken 97 times.
✓ Branch 2 taken 234 times.
✓ Branch 3 taken 112 times.
25088 switch(tempitem.family)
9498 {
9499 case itype_divinefire:
9500
2/2
✓ Branch 0 taken 92 times.
✓ Branch 1 taken 5 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG9, version < 0x255); //Strong Fire
9501
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 81 times.
97 SETFLAG(tempitem.flags, ITEM_FLAG10, version < 0x250); //Magic Fire
9502 97 tempitem.flags |= ITEM_FLAG11; //Divine Fire
9503 97 break;
9504 case itype_candle:
9505
2/2
✓ Branch 0 taken 114 times.
✓ Branch 1 taken 120 times.
234 SETFLAG(tempitem.flags, ITEM_FLAG9, tempitem.fam_type > 1); //Strong Fire
9506 234 tempitem.flags &= ~ITEM_FLAG10; //Magic Fire
9507 234 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9508 234 break;
9509 case itype_book:
9510 112 tempitem.flags |= ITEM_FLAG9; //Strong Fire
9511 112 tempitem.flags |= ITEM_FLAG10; //Magic Fire
9512 112 tempitem.flags &= ~ITEM_FLAG11; //Divine Fire
9513 112 break;
9514 }
9515 25088 }
9516
9517
2/2
✓ Branch 0 taken 30880 times.
✓ Branch 1 taken 2144 times.
33024 if(tempitem.fam_type==0) // Always do this
9518 2144 tempitem.fam_type=1;
9519
9520 33024 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9521 33024 }
9522
9523 129 return 0;
9524 129 }
9525
9526 static bool did_init_def_items = false;
9527 66240 void init_def_items()
9528 {
9529
2/2
✓ Branch 0 taken 66194 times.
✓ Branch 1 taken 46 times.
66240 if(did_init_def_items) return;
9530 46 did_init_def_items = true;
9531 46 default_items[3].cost_counter[1] = crBOMBS;
9532 46 default_items[13].cost_counter[1] = crARROWS;
9533 46 default_items[14].cost_counter[1] = crARROWS;
9534 46 default_items[48].cost_counter[1] = crSBOMBS;
9535 46 default_items[57].cost_counter[1] = crARROWS;
9536 66240 }
9537 66240 void reset_itembuf(itemdata *item, int32_t id)
9538 {
9539 66240 init_def_items();
9540
2/2
✓ Branch 0 taken 28250 times.
✓ Branch 1 taken 37990 times.
66240 if(id<iLast)
9541 {
9542 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9543 37990 word tile = item->tile;
9544 37990 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9545 37990 int32_t ltm = item->ltm;
9546
9547 37990 memcpy(item,&default_items[id],sizeof(itemdata));
9548 37990 item->tile = tile;
9549 37990 item->misc_flags = miscs;
9550 37990 item->csets = cset;
9551 37990 item->frames = frames;
9552 37990 item->speed = speed;
9553 37990 item->delay = delay;
9554 37990 item->ltm = ltm;
9555 37990 }
9556 66240 }
9557
9558 15872 void reset_itemname(int32_t id)
9559 {
9560 15872 sprintf(item_string[id],"zz%03d",id);
9561
9562
2/2
✓ Branch 0 taken 7006 times.
✓ Branch 1 taken 8866 times.
15872 if(id < iLast)
9563 8866 strcpy(item_string[id],old_item_string[id]);
9564 15872 }
9565
9566 129 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9567 {
9568 129 word weapons_to_read=MAXWPNS;
9569 int32_t dummy;
9570 byte padding;
9571 wpndata tempweapon;
9572 129 word s_version=0, s_cversion=0;
9573
9574
9575
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x186)
9576 {
9577 weapons_to_read=64;
9578 }
9579
9580
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x185)
9581 {
9582 weapons_to_read=32;
9583 }
9584
9585
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
9586 {
9587 125 weapons_to_read=0;
9588
9589 //section version info
9590
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
9591 {
9592 return qe_invalid;
9593 }
9594
9595 125 FFCore.quest_format[vWeaponSprites] = s_version;
9596
9597 //al_trace("Weapons version %d\n", s_version);
9598
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_cversion,f))
9599 {
9600 return qe_invalid;
9601 }
9602
9603 //section size
9604
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
9605 {
9606 return qe_invalid;
9607 }
9608
9609 //finally... section data
9610
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&weapons_to_read,f))
9611 {
9612 return qe_invalid;
9613 }
9614
9615
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if (!(weapons_to_read >= 0 && weapons_to_read <= MAXWPNS))
9616 {
9617 return qe_invalid;
9618 }
9619 125 }
9620
9621
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version>2)
9622 {
9623
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i=0; i<weapons_to_read; i++)
9624 {
9625 char tempname[64];
9626
9627
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if(!pfread(tempname, 64, f))
9628 {
9629 return qe_invalid;
9630 }
9631
9632 28928 weapon_string[i][0] = '\0';
9633 28928 strncat(weapon_string[i], tempname, 64 - 1);
9634 28928 }
9635
9636
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<4)
9637 {
9638 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9639 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9640 }
9641
9642
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version<5)
9643 {
9644 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9645 }
9646
9647 /*
9648 if (s_version<6)
9649 {
9650 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9651 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9652 }
9653 */
9654 113 }
9655 else
9656 {
9657
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 16 times.
4112 for(int32_t i=0; i<MAXWPNS; i++)
9658 4096 reset_weaponname(i);
9659 }
9660
9661
2/2
✓ Branch 0 taken 30768 times.
✓ Branch 1 taken 129 times.
30897 for(int32_t i=0; i<weapons_to_read; i++)
9662 {
9663 30768 word oldtile = 0;
9664
2/2
✓ Branch 0 taken 8704 times.
✓ Branch 1 taken 22064 times.
30768 if (s_version < 8)
9665 {
9666
1/2
✓ Branch 0 taken 22064 times.
✗ Branch 1 not taken.
22064 if (!p_igetw(&oldtile, f))
9667 return qe_invalid;
9668 22064 }
9669
9670
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.misc,f))
9671 {
9672 return qe_invalid;
9673 }
9674
9675
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.csets,f))
9676 {
9677 return qe_invalid;
9678 }
9679
9680
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.frames,f))
9681 {
9682 return qe_invalid;
9683 }
9684
9685
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.speed,f))
9686 {
9687 return qe_invalid;
9688 }
9689
9690
1/2
✓ Branch 0 taken 30768 times.
✗ Branch 1 not taken.
30768 if(!p_getc(&tempweapon.type,f))
9691 {
9692 return qe_invalid;
9693 }
9694
9695
2/2
✓ Branch 0 taken 21552 times.
✓ Branch 1 taken 9216 times.
30768 if ( s_version >= 7 )
9696 {
9697
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetw(&tempweapon.script,f))
9698 {
9699 return qe_invalid;
9700 }
9701
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if(!p_igetl(&tempweapon.tile,f))
9702 {
9703 return qe_invalid;
9704 }
9705 9216 }
9706
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 21552 times.
30768 if ( s_version < 7 )
9707 {
9708 21552 tempweapon.tile = oldtile;
9709 21552 }
9710
9711
2/2
✓ Branch 0 taken 29744 times.
✓ Branch 1 taken 1024 times.
30768 if(Header->zelda_version < 0x193)
9712 {
9713
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&padding,f))
9714 {
9715 return qe_invalid;
9716 }
9717 1024 }
9718
9719
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 1840 times.
30768 if(s_version < 6)
9720 {
9721
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1836 times.
1840 if(i==ewFIRETRAIL)
9722 {
9723 4 tempweapon.misc |= WF_BEHIND;
9724 4 }
9725 else
9726 1836 tempweapon.misc &= ~WF_BEHIND;
9727 1840 }
9728
9729 30768 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9730 30768 }
9731
9732
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<2)
9733 {
9734 16 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9735 16 }
9736
9737
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version<5)
9738 {
9739 16 wpnsbuf[iwQuarterHearts].tile=1;
9740 16 wpnsbuf[iwQuarterHearts].csets=1;
9741 16 }
9742
9743
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x176)
9744 {
9745 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9746 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9747 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9748 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9749 }
9750
9751
2/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
129 if((Header->zelda_version < 0x192)||
9752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9753 {
9754 4 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9755 4 }
9756
9757
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if((Header->zelda_version < 0x210))
9758 {
9759 4 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9760 4 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9761 4 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9762 4 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9763 4 }
9764
9765 129 return 0;
9766 129 }
9767
9768 129 void init_guys(int32_t guyversion)
9769 {
9770
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<MAXGUYS; i++)
9771 {
9772 66048 guysbuf[i] = default_guys[0];
9773 66048 }
9774
9775
2/2
✓ Branch 0 taken 22833 times.
✓ Branch 1 taken 129 times.
22962 for(int32_t i=0; i<OLDMAXGUYS; i++)
9776 {
9777 22833 guysbuf[i] = default_guys[i];
9778
2/2
✓ Branch 0 taken 22575 times.
✓ Branch 1 taken 258 times.
22833 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].misc10==1) ? iwLargeShadow : iwShadow;
9779 22833 guysbuf[i].spr_death = iwDeath;
9780 22833 guysbuf[i].spr_spawn = iwSpawn;
9781 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9782
4/4
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 20001 times.
✓ Branch 2 taken 2816 times.
✓ Branch 3 taken 16 times.
22833 if(guyversion<=3 && i==ePATRABS)
9783 {
9784 16 guysbuf[i].bosspal=spDIG;
9785 16 guysbuf[i].cset=14;
9786 16 guysbuf[i].misc9=14;
9787 16 }
9788
9789
2/2
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 2832 times.
22833 if(guyversion<=3)
9790 {
9791 // Rope/Ghini Flash rules
9792
2/2
✓ Branch 0 taken 708 times.
✓ Branch 1 taken 2124 times.
2832 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9793 {
9794
2/2
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
2124 if(i==eROPE2)
9795 {
9796 12 guysbuf[i].flags2 &= ~guy_flashing;
9797 12 }
9798 2124 }
9799
9800
2/2
✓ Branch 0 taken 2301 times.
✓ Branch 1 taken 531 times.
2832 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9801 {
9802
12/12
✓ Branch 0 taken 528 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 525 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 522 times.
✓ Branch 5 taken 3 times.
✓ Branch 6 taken 519 times.
✓ Branch 7 taken 3 times.
✓ Branch 8 taken 516 times.
✓ Branch 9 taken 3 times.
✓ Branch 10 taken 3 times.
✓ Branch 11 taken 513 times.
531 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9803 {
9804 18 guysbuf[i].flags2 &= ~guy_flashing;
9805 18 }
9806 531 }
9807
9808
2/2
✓ Branch 0 taken 2816 times.
✓ Branch 1 taken 16 times.
2832 if(i==eGHINI2)
9809 {
9810
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 3 times.
16 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9811 {
9812 3 guysbuf[i].flags2 |= guy_blinking;
9813 3 }
9814
9815
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9816 {
9817 guysbuf[i].flags2 |= guy_transparent;
9818 }
9819 16 }
9820 2832 }
9821
9822 // Darknut fix
9823
10/10
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22575 times.
✓ Branch 3 taken 129 times.
✓ Branch 4 taken 22446 times.
✓ Branch 5 taken 129 times.
✓ Branch 6 taken 22317 times.
✓ Branch 7 taken 129 times.
✓ Branch 8 taken 129 times.
✓ Branch 9 taken 22188 times.
22833 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9824 {
9825
2/2
✓ Branch 0 taken 435 times.
✓ Branch 1 taken 210 times.
645 if(get_qr(qr_NEWENEMYTILES))
9826 {
9827 435 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9828 435 guysbuf[i].s_width=guysbuf[i].e_width;
9829 435 guysbuf[i].s_height=guysbuf[i].e_height;
9830 435 }
9831 210 else guysbuf[i].s_tile=860;
9832
9833
2/2
✓ Branch 0 taken 565 times.
✓ Branch 1 taken 80 times.
645 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9834 {
9835 80 guysbuf[i].flags |= guy_bkshield;
9836 80 }
9837 645 }
9838
9839
4/4
✓ Branch 0 taken 22704 times.
✓ Branch 1 taken 129 times.
✓ Branch 2 taken 22825 times.
✓ Branch 3 taken 8 times.
22833 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9840 {
9841 8 guysbuf[i].misc3 = (i==eFGELTRIB ? eFZOL : eZOL);
9842 8 }
9843 22833 }
9844 129 }
9845
9846 4096 void reset_weaponname(int32_t i)
9847 {
9848
2/2
✓ Branch 0 taken 1408 times.
✓ Branch 1 taken 2688 times.
4096 if(i<wLast)
9849 {
9850 1408 strcpy(weapon_string[i],old_weapon_string[i]);
9851 1408 }
9852 else
9853 2688 sprintf(weapon_string[i],"zz%03d",i);
9854 4096 }
9855
9856 129 void init_item_drop_sets()
9857 {
9858
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9859 {
9860 // item_drop_sets[i] = default_item_drop_sets[0];
9861 33024 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9862 33024 }
9863
9864
2/2
✓ Branch 0 taken 1677 times.
✓ Branch 1 taken 129 times.
1806 for(int32_t i=0; i<isMAX; i++)
9865 {
9866 1677 item_drop_sets[i] = default_item_drop_sets[i];
9867
9868 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9869
2/2
✓ Branch 0 taken 16770 times.
✓ Branch 1 taken 1677 times.
18447 for(int32_t j=0; j<10; ++j)
9870 {
9871 16770 int32_t it = item_drop_sets[i].item[j];
9872
9873
3/4
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 4994 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 756 times.
16770 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9874
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 11020 times.
11776 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9875 {
9876 756 item_drop_sets[i].chance[j+1]=0;
9877 756 }
9878
3/4
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 15498 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 516 times.
16014 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9879 {
9880 item_drop_sets[i].chance[j+1]=0;
9881 }
9882
9883 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9884
2/2
✓ Branch 0 taken 16762 times.
✓ Branch 1 taken 8 times.
16770 if(itemsbuf[it].family == itype_misc)
9885 {
9886 // If a non-gameplay item was selected, then item drop was aborted.
9887 // Reflect this by increasing the 'Nothing' chance accordingly.
9888 8 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9889 8 item_drop_sets[i].chance[j+1]=0;
9890 8 }
9891 16770 }
9892 1677 }
9893 129 }
9894
9895 125 void init_favorites()
9896 {
9897
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9898 {
9899 37500 favorite_combos[i]=-1;
9900 37500 }
9901
9902
2/2
✓ Branch 0 taken 37500 times.
✓ Branch 1 taken 125 times.
37625 for(int32_t i=0; i<MAXFAVORITECOMBOALIASES; i++)
9903 {
9904 37500 favorite_comboaliases[i]=-1;
9905 37500 }
9906 125 }
9907
9908 const char *ctype_name[cMAX]=
9909 {
9910 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9911 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9912 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9913 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9914 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9915 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9916 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9917 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9918 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9919 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9920 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9921 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9922 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9923 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9924 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9925 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9926 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9927 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9928 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9929 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9930 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9931 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9932 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9933 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9934 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9935 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9936 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9937 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9938
9939 };
9940
9941 224 int32_t init_combo_classes()
9942 {
9943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224 times.
224 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9944
2/2
✓ Branch 0 taken 40544 times.
✓ Branch 1 taken 224 times.
40768 for(int32_t i=0; i<cMAX; i++)
9945 {
9946 40544 combo_class_buf[i] = default_combo_classes[i];
9947
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40544 times.
40544 if ( char const* nm = zi->getComboTypeName(i) )
9948 {
9949 40544 size_t len = strlen(nm);
9950
2/2
✓ Branch 0 taken 2594816 times.
✓ Branch 1 taken 40544 times.
2635360 for ( size_t q = 0; q < 64; q++ )
9951 {
9952
2/2
✓ Branch 0 taken 599200 times.
✓ Branch 1 taken 1995616 times.
2594816 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9953 2594816 }
9954 40544 }
9955 40544 }
9956
9957 224 return 0;
9958 }
9959
9960 97 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9961 {
9962
1/2
✓ Branch 0 taken 97 times.
✗ Branch 1 not taken.
97 assert(v_herosprites < 6);
9963 //these are here to bypass compiler warnings about unused arguments
9964 97 cv_herosprites=cv_herosprites;
9965
9966 97 zinit.hero_swim_speed=67; //default
9967 97 setupherotiles(zinit.heroAnimationStyle);
9968 97 setupherodefenses();
9969 97 setupherooffsets();
9970
9971
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 77 times.
97 if(v_herosprites>=0)
9972 {
9973 word tile, tile2;
9974 byte flip, extend, dummy_byte;
9975
9976
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9977 {
9978
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
9979 {
9980 return qe_invalid;
9981 }
9982
9983
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
9984 {
9985 return qe_invalid;
9986 }
9987
9988
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
9989 {
9990 return qe_invalid;
9991 }
9992
9993 308 walkspr[i][spr_tile]=(int32_t)tile;
9994 308 walkspr[i][spr_flip]=(int32_t)flip;
9995 308 walkspr[i][spr_extend]=(int32_t)extend;
9996 308 }
9997
9998
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
9999 {
10000
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10001 {
10002 return qe_invalid;
10003 }
10004
10005
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10006 {
10007 return qe_invalid;
10008 }
10009
10010
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10011 {
10012 return qe_invalid;
10013 }
10014
10015 308 stabspr[i][spr_tile]=(int32_t)tile;
10016 308 stabspr[i][spr_flip]=(int32_t)flip;
10017 308 stabspr[i][spr_extend]=(int32_t)extend;
10018 308 }
10019
10020
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10021 {
10022
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10023 {
10024 return qe_invalid;
10025 }
10026
10027
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10028 {
10029 return qe_invalid;
10030 }
10031
10032
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10033 {
10034 return qe_invalid;
10035 }
10036
10037 308 slashspr[i][spr_tile]=(int32_t)tile;
10038 308 slashspr[i][spr_flip]=(int32_t)flip;
10039 308 slashspr[i][spr_extend]=(int32_t)extend;
10040 308 }
10041
10042
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10043 {
10044
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10045 {
10046 return qe_invalid;
10047 }
10048
10049
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10050 {
10051 return qe_invalid;
10052 }
10053
10054
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10055 {
10056 return qe_invalid;
10057 }
10058
10059 308 floatspr[i][spr_tile]=(int32_t)tile;
10060 308 floatspr[i][spr_flip]=(int32_t)flip;
10061 308 floatspr[i][spr_extend]=(int32_t)extend;
10062 308 }
10063
10064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>1)
10065 {
10066
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10067 {
10068
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10069 {
10070 return qe_invalid;
10071 }
10072
10073
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10074 {
10075 return qe_invalid;
10076 }
10077
10078
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10079 {
10080 return qe_invalid;
10081 }
10082
10083 308 swimspr[i][spr_tile]=(int32_t)tile;
10084 308 swimspr[i][spr_flip]=(int32_t)flip;
10085 308 swimspr[i][spr_extend]=(int32_t)extend;
10086 308 }
10087 77 }
10088
10089
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10090 {
10091
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10092 {
10093 return qe_invalid;
10094 }
10095
10096
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10097 {
10098 return qe_invalid;
10099 }
10100
10101
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10102 {
10103 return qe_invalid;
10104 }
10105
10106 308 divespr[i][spr_tile]=(int32_t)tile;
10107 308 divespr[i][spr_flip]=(int32_t)flip;
10108 308 divespr[i][spr_extend]=(int32_t)extend;
10109 308 }
10110
10111
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10112 {
10113
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10114 {
10115 return qe_invalid;
10116 }
10117
10118
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10119 {
10120 return qe_invalid;
10121 }
10122
10123
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10124 {
10125 return qe_invalid;
10126 }
10127
10128 308 poundspr[i][spr_tile]=(int32_t)tile;
10129 308 poundspr[i][spr_flip]=(int32_t)flip;
10130 308 poundspr[i][spr_extend]=(int32_t)extend;
10131 308 }
10132
10133
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_igetw(&tile,f))
10134 {
10135 return qe_invalid;
10136 }
10137
10138 77 flip=0;
10139
10140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>0)
10141 {
10142
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&flip,f))
10143 {
10144 return qe_invalid;
10145 }
10146 77 }
10147
10148
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&extend,f))
10149 {
10150 return qe_invalid;
10151 }
10152
10153 77 castingspr[spr_tile]=(int32_t)tile;
10154 77 castingspr[spr_flip]=(int32_t)flip;
10155 77 castingspr[spr_extend]=(int32_t)extend;
10156
10157
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(v_herosprites>0)
10158 {
10159 77 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10160
2/2
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 77 times.
231 for(int32_t i=0; i<2; i++)
10161 {
10162
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 154 times.
462 for(int32_t j=0; j<num_holdsprs; j++)
10163 {
10164
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10165 {
10166 return qe_invalid;
10167 }
10168
10169
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10170 {
10171 return qe_invalid;
10172 }
10173
10174
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10175 {
10176 return qe_invalid;
10177 }
10178
10179 308 holdspr[i][j][spr_tile]=(int32_t)tile;
10180 308 holdspr[i][j][spr_flip]=(int32_t)flip;
10181 308 holdspr[i][j][spr_extend]=(int32_t)extend;
10182 308 }
10183 154 }
10184 77 }
10185 else
10186 {
10187 for(int32_t i=0; i<2; i++)
10188 {
10189 if(!p_igetw(&tile,f))
10190 {
10191 return qe_invalid;
10192 }
10193
10194 if(!p_igetw(&tile2,f))
10195 {
10196 return qe_invalid;
10197 }
10198
10199 if(!p_getc(&extend,f))
10200 {
10201 return qe_invalid;
10202 }
10203
10204 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10205 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10206 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10207 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10208 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10209 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10210 }
10211 }
10212
10213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>2)
10214 {
10215
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10216 {
10217
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10218 {
10219 return qe_invalid;
10220 }
10221
10222
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10223 {
10224 return qe_invalid;
10225 }
10226
10227
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10228 {
10229 return qe_invalid;
10230 }
10231
10232 308 jumpspr[i][spr_tile]=(int32_t)tile;
10233 308 jumpspr[i][spr_flip]=(int32_t)flip;
10234 308 jumpspr[i][spr_extend]=(int32_t)extend;
10235 308 }
10236 77 }
10237
10238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>3)
10239 {
10240
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i=0; i<4; i++)
10241 {
10242
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_igetw(&tile,f))
10243 {
10244 return qe_invalid;
10245 }
10246
10247
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&flip,f))
10248 {
10249 return qe_invalid;
10250 }
10251
10252
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if(!p_getc(&extend,f))
10253 {
10254 return qe_invalid;
10255 }
10256
10257 308 chargespr[i][spr_tile]=(int32_t)tile;
10258 308 chargespr[i][spr_flip]=(int32_t)flip;
10259 308 chargespr[i][spr_extend]=(int32_t)extend;
10260 308 }
10261 77 }
10262
10263
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(v_herosprites>4)
10264 {
10265
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(!p_getc(&dummy_byte,f))
10266 {
10267 return qe_invalid;
10268 }
10269
10270 77 zinit.hero_swim_speed=(byte)dummy_byte;
10271 77 }
10272
10273 77 memset(frozenspr, 0, sizeof(frozenspr));
10274 77 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10275 77 memset(onfirespr, 0, sizeof(onfirespr));
10276 77 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10277 77 memset(diggingspr, 0, sizeof(diggingspr));
10278 77 memset(usingrodspr, 0, sizeof(usingrodspr));
10279 77 memset(usingcanespr, 0, sizeof(usingcanespr));
10280 77 memset(pushingspr, 0, sizeof(pushingspr));
10281 77 memset(liftingspr, 0, sizeof(liftingspr));
10282 77 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10283 77 memset(stunnedspr, 0, sizeof(stunnedspr));
10284 77 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10285 77 memset(fallingspr, 0, sizeof(fallingspr));
10286 77 memset(shockedspr, 0, sizeof(shockedspr));
10287 77 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10288 77 memset(pullswordspr, 0, sizeof(pullswordspr));
10289 77 memset(readingspr, 0, sizeof(readingspr));
10290 77 memset(slash180spr, 0, sizeof(slash180spr));
10291 77 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10292 77 memset(dashspr, 0, sizeof(dashspr));
10293 77 memset(bonkspr, 0, sizeof(bonkspr));
10294 77 memset(medallionsprs, 0, sizeof(medallionsprs));
10295 77 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10296 77 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10297
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t q = 0; q < 4; ++q)
10298 {
10299
2/2
✓ Branch 0 taken 924 times.
✓ Branch 1 taken 308 times.
1232 for(int32_t p = 0; p < 3; ++p)
10300 {
10301 924 drowningspr[q][p] = divespr[q][p];
10302 924 drowning_lavaspr[q][p] = divespr[q][p];
10303 924 }
10304 308 }
10305 77 memset(sideswimspr, 0, sizeof(sideswimspr));
10306 77 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10307 77 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10308 77 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10309 77 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10310 77 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10311 77 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10312 77 }
10313
10314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97 times.
97 if(FFCore.quest_format[vInitData] < 34)
10315 {
10316 97 bool fastswim = zinit.hero_swim_speed > 60;
10317 // '2/3' or '1/2'
10318 97 zinit.hero_swim_mult = fastswim ? 2 : 1;
10319 97 zinit.hero_swim_div = fastswim ? 3 : 2;
10320 97 }
10321 97 return 0;
10322 97 }
10323
10324 6120 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10325 {
10326 6120 arr[spr_tile] = tile;
10327
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_flip] = (flip > 3 ? 0 : flip);
10328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6120 times.
6120 arr[spr_extend] = (ext > 2 ? 0 : ext);
10329 6120 }
10330 //Used to read the player sprites as int32_t, not word.
10331 36 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10332 {
10333 //these are here to bypass compiler warnings about unused arguments
10334 36 cv_herosprites=cv_herosprites;
10335
10336 36 zinit.hero_swim_speed=67; //default
10337 36 setupherotiles(zinit.heroAnimationStyle);
10338 36 setupherodefenses();
10339 36 setupherooffsets();
10340
10341 int32_t tile, tile2;
10342 byte flip, extend, dummy_byte;
10343
10344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>=0)
10345 {
10346
10347
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10348 {
10349
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10350 {
10351 return qe_invalid;
10352 }
10353
10354
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10355 {
10356 return qe_invalid;
10357 }
10358
10359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10360 {
10361 return qe_invalid;
10362 }
10363
10364 144 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10365 144 }
10366
10367
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10368 {
10369
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10370 {
10371 return qe_invalid;
10372 }
10373
10374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10375 {
10376 return qe_invalid;
10377 }
10378
10379
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10380 {
10381 return qe_invalid;
10382 }
10383
10384 144 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10385 144 }
10386
10387
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10388 {
10389
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10390 {
10391 return qe_invalid;
10392 }
10393
10394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10395 {
10396 return qe_invalid;
10397 }
10398
10399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10400 {
10401 return qe_invalid;
10402 }
10403
10404 144 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10405 144 }
10406
10407
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10408 {
10409
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10410 {
10411 return qe_invalid;
10412 }
10413
10414
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10415 {
10416 return qe_invalid;
10417 }
10418
10419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10420 {
10421 return qe_invalid;
10422 }
10423
10424 144 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10425 144 }
10426
10427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>1)
10428 {
10429
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10430 {
10431
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10432 {
10433 return qe_invalid;
10434 }
10435
10436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10437 {
10438 return qe_invalid;
10439 }
10440
10441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10442 {
10443 return qe_invalid;
10444 }
10445
10446 144 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10447 144 }
10448 36 }
10449
10450
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10451 {
10452
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10453 {
10454 return qe_invalid;
10455 }
10456
10457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10458 {
10459 return qe_invalid;
10460 }
10461
10462
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10463 {
10464 return qe_invalid;
10465 }
10466
10467 144 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10468 144 }
10469
10470
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10471 {
10472
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10473 {
10474 return qe_invalid;
10475 }
10476
10477
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10478 {
10479 return qe_invalid;
10480 }
10481
10482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10483 {
10484 return qe_invalid;
10485 }
10486
10487 144 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10488 144 }
10489
10490
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
10491 {
10492 return qe_invalid;
10493 }
10494
10495 36 flip=0;
10496
10497
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>0)
10498 {
10499
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
10500 {
10501 return qe_invalid;
10502 }
10503 36 }
10504
10505
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
10506 {
10507 return qe_invalid;
10508 }
10509
10510 36 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10511
10512
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>0)
10513 {
10514 36 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10515
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 36 times.
108 for(int32_t i=0; i<2; i++)
10516 {
10517
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 72 times.
288 for(int32_t j=0; j<num_holdsprs; j++)
10518 {
10519
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_igetl(&tile,f))
10520 {
10521 return qe_invalid;
10522 }
10523
10524
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&flip,f))
10525 {
10526 return qe_invalid;
10527 }
10528
10529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216 times.
216 if(!p_getc(&extend,f))
10530 {
10531 return qe_invalid;
10532 }
10533
10534 216 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10535 216 }
10536 72 }
10537 36 }
10538 else
10539 {
10540 for(int32_t i=0; i<2; i++)
10541 {
10542 if(!p_igetl(&tile,f))
10543 {
10544 return qe_invalid;
10545 }
10546
10547 if(!p_igetl(&tile2,f))
10548 {
10549 return qe_invalid;
10550 }
10551
10552 if(!p_getc(&extend,f))
10553 {
10554 return qe_invalid;
10555 }
10556
10557 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10558 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10559 }
10560 }
10561
10562
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>2)
10563 {
10564
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10565 {
10566
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10567 {
10568 return qe_invalid;
10569 }
10570
10571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10572 {
10573 return qe_invalid;
10574 }
10575
10576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10577 {
10578 return qe_invalid;
10579 }
10580
10581 144 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10582 144 }
10583 36 }
10584
10585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>3)
10586 {
10587
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t i=0; i<4; i++)
10588 {
10589
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10590 {
10591 return qe_invalid;
10592 }
10593
10594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10595 {
10596 return qe_invalid;
10597 }
10598
10599
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10600 {
10601 return qe_invalid;
10602 }
10603
10604 144 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10605 144 }
10606 36 }
10607
10608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
36 if(v_herosprites>4)
10609 {
10610
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&dummy_byte,f))
10611 {
10612 return qe_invalid;
10613 }
10614
10615 36 zinit.hero_swim_speed=(byte)dummy_byte;
10616 36 }
10617
10618
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(v_herosprites>6)
10619 {
10620
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10621 {
10622
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10623 return qe_invalid;
10624
10625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10626 return qe_invalid;
10627
10628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10629 return qe_invalid;
10630
10631 144 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10632 144 }
10633
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10634 {
10635
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10636 return qe_invalid;
10637
10638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10639 return qe_invalid;
10640
10641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10642 return qe_invalid;
10643
10644 144 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10645 144 }
10646
10647
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10648 {
10649
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10650 return qe_invalid;
10651
10652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10653 return qe_invalid;
10654
10655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10656 return qe_invalid;
10657
10658 144 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10659 144 }
10660
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10661 {
10662
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10663 return qe_invalid;
10664
10665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10669 return qe_invalid;
10670
10671 144 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10672 144 }
10673
10674
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10675 {
10676
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10677 return qe_invalid;
10678
10679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10680 return qe_invalid;
10681
10682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10683 return qe_invalid;
10684
10685 144 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10686 144 }
10687
10688
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10689 {
10690
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10691 return qe_invalid;
10692
10693
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10694 return qe_invalid;
10695
10696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10697 return qe_invalid;
10698
10699 144 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10700 144 }
10701
10702
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10703 {
10704
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10705 return qe_invalid;
10706
10707
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10708 return qe_invalid;
10709
10710
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10711 return qe_invalid;
10712
10713 144 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10714 144 }
10715
10716
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10717 {
10718
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10719 return qe_invalid;
10720
10721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10722 return qe_invalid;
10723
10724
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10725 return qe_invalid;
10726
10727 144 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10728 144 }
10729
10730
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10731 {
10732
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10733 return qe_invalid;
10734
10735
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10736 return qe_invalid;
10737
10738
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10739 return qe_invalid;
10740
10741 144 byte frames = 0;
10742
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 136 times.
144 if(v_herosprites > 15)
10743 {
10744
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 136 times.
136 if(!p_getc(&frames,f))
10745 return qe_invalid;
10746 136 }
10747
10748 144 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10749 144 liftingspr[q][spr_frames] = frames;
10750 144 }
10751
10752
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10753 {
10754
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10755 return qe_invalid;
10756
10757
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10758 return qe_invalid;
10759
10760
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10761 return qe_invalid;
10762
10763 144 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10764 144 }
10765
10766
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10767 {
10768
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10769 return qe_invalid;
10770
10771
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10772 return qe_invalid;
10773
10774
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10775 return qe_invalid;
10776
10777 144 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10778 144 }
10779
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10780 {
10781
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10782 return qe_invalid;
10783
10784
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10785 return qe_invalid;
10786
10787
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10788 return qe_invalid;
10789
10790 144 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10791 144 }
10792
10793
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10794 {
10795
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10796 return qe_invalid;
10797
10798
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10799 return qe_invalid;
10800
10801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10802 return qe_invalid;
10803
10804 144 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10805 144 }
10806
10807
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10808 {
10809
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10810 return qe_invalid;
10811
10812
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10813 return qe_invalid;
10814
10815
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10816 return qe_invalid;
10817
10818 144 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10819 144 }
10820
10821
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10822 {
10823
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10824 return qe_invalid;
10825
10826
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10827 return qe_invalid;
10828
10829
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10830 return qe_invalid;
10831
10832 144 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10833 144 }
10834
10835
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10836 {
10837
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10838 return qe_invalid;
10839
10840
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10841 return qe_invalid;
10842
10843
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10844 return qe_invalid;
10845
10846 144 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10847 144 }
10848
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10849 {
10850
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10851 return qe_invalid;
10852
10853
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10854 return qe_invalid;
10855
10856
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10857 return qe_invalid;
10858
10859 144 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10860 144 }
10861
10862
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10863 {
10864
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10865 return qe_invalid;
10866
10867
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
10868 return qe_invalid;
10869
10870
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10871 return qe_invalid;
10872
10873 144 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10874 144 }
10875
10876
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10877 {
10878
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10879 return qe_invalid;
10880
10881
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10882 return qe_invalid;
10883
10884
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10885 return qe_invalid;
10886
10887 144 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10888 144 }
10889
10890
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10891 {
10892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&tile,f))
10893 return qe_invalid;
10894
10895
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10896 return qe_invalid;
10897
10898
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
10899 return qe_invalid;
10900
10901 144 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10902 144 }
10903
10904
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10905 {
10906
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10907 return qe_invalid;
10908
10909
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10913 return qe_invalid;
10914
10915 144 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10916 144 }
10917
10918
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10919 {
10920
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10921 return qe_invalid;
10922
10923
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10924 return qe_invalid;
10925
10926
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10927 return qe_invalid;
10928
10929 144 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10930 144 }
10931
10932
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10933 {
10934
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
10935 return qe_invalid;
10936
10937
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&flip,f))
10938 return qe_invalid;
10939
10940
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_getc(&extend,f))
10941 return qe_invalid;
10942
10943 144 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10944 144 }
10945
10946
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10947 {
10948
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
10949 return qe_invalid;
10950
10951
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&flip,f))
10952 return qe_invalid;
10953
10954
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_getc(&extend,f))
10955 return qe_invalid;
10956
10957 108 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10958 108 }
10959 36 }
10960 else
10961 {
10962 memset(frozenspr, 0, sizeof(frozenspr));
10963 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10964 memset(onfirespr, 0, sizeof(onfirespr));
10965 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10966 memset(diggingspr, 0, sizeof(diggingspr));
10967 memset(usingrodspr, 0, sizeof(usingrodspr));
10968 memset(usingcanespr, 0, sizeof(usingcanespr));
10969 memset(pushingspr, 0, sizeof(pushingspr));
10970 memset(liftingspr, 0, sizeof(liftingspr));
10971 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10972 memset(stunnedspr, 0, sizeof(stunnedspr));
10973 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10974 memset(fallingspr, 0, sizeof(fallingspr));
10975 memset(shockedspr, 0, sizeof(shockedspr));
10976 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10977 memset(pullswordspr, 0, sizeof(pullswordspr));
10978 memset(readingspr, 0, sizeof(readingspr));
10979 memset(slash180spr, 0, sizeof(slash180spr));
10980 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10981 memset(dashspr, 0, sizeof(dashspr));
10982 memset(bonkspr, 0, sizeof(bonkspr));
10983 memset(medallionsprs, 0, sizeof(medallionsprs));
10984 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10985 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10986 for(int32_t q = 0; q < 4; ++q)
10987 {
10988 for(int32_t p = 0; p < 3; ++p)
10989 {
10990 drowningspr[q][p] = divespr[q][p];
10991 drowning_lavaspr[q][p] = divespr[q][p];
10992 }
10993 }
10994 }
10995
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 8)
10996 {
10997
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
10998 {
10999
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11000 return qe_invalid;
11001
11002
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11003 return qe_invalid;
11004
11005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11006 return qe_invalid;
11007
11008 144 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11009 144 }
11010 36 }
11011 else
11012 {
11013 memset(sideswimspr, 0, sizeof(sideswimspr));
11014 }
11015
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 9)
11016 {
11017
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11018 {
11019
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11020 return qe_invalid;
11021
11022
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11023 return qe_invalid;
11024
11025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11026 return qe_invalid;
11027
11028 144 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11029 144 }
11030
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11031 {
11032
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11033 return qe_invalid;
11034
11035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11036 return qe_invalid;
11037
11038
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11039 return qe_invalid;
11040
11041 144 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11042 144 }
11043
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11044 {
11045
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11046 return qe_invalid;
11047
11048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11049 return qe_invalid;
11050
11051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11052 return qe_invalid;
11053
11054 144 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11055 144 }
11056
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11057 {
11058
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11059 return qe_invalid;
11060
11061
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11062 return qe_invalid;
11063
11064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11065 return qe_invalid;
11066
11067 144 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11068 144 }
11069 36 }
11070 else
11071 {
11072 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11073 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11074 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11075 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11076 }
11077
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 10)
11078 {
11079
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11080 {
11081 int32_t hmr;
11082
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_igetl(&hmr,f))
11083 return qe_invalid;
11084
11085 144 hammeroffsets[q] = hmr;
11086 144 }
11087 36 }
11088 else
11089 {
11090 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11091 }
11092
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 11)
11093 {
11094
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 36 times.
144 for(int32_t q = 0; q < 3; ++q)
11095 {
11096
1/2
✓ Branch 0 taken 108 times.
✗ Branch 1 not taken.
108 if(!p_igetl(&tile,f))
11097 return qe_invalid;
11098
11099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&flip,f))
11100 return qe_invalid;
11101
11102
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108 times.
108 if(!p_getc(&extend,f))
11103 return qe_invalid;
11104
11105 108 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11106 108 }
11107 36 }
11108 else
11109 {
11110 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11111 }
11112
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 12)
11113 {
11114
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tile,f))
11115 return qe_invalid;
11116
11117
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&flip,f))
11118 return qe_invalid;
11119
11120
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_getc(&extend,f))
11121 return qe_invalid;
11122 36 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11123
11124 36 }
11125 else
11126 {
11127 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11128 }
11129
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 13)
11130 {
11131
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11132 {
11133
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11134 return qe_invalid;
11135
11136
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11137 return qe_invalid;
11138
11139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11140 return qe_invalid;
11141
11142 144 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11143 144 }
11144 36 }
11145 else
11146 {
11147 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11148 }
11149
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 14)
11150 {
11151
2/2
✓ Branch 0 taken 144 times.
✓ Branch 1 taken 36 times.
180 for(int32_t q = 0; q < 4; ++q)
11152 {
11153
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(!p_igetl(&tile,f))
11154 return qe_invalid;
11155
11156
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&flip,f))
11157 return qe_invalid;
11158
11159
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if(!p_getc(&extend,f))
11160 return qe_invalid;
11161
11162 144 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11163 144 }
11164 36 }
11165 else
11166 {
11167 memset(revslashspr, 0, sizeof(revslashspr));
11168 }
11169
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if (v_herosprites > 7)
11170 {
11171 36 int32_t num_defense = wMax;
11172 36 byte def = 0;
11173
11174 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11175 /*if(v_herosprites > [x])
11176 * {
11177 * num_defense = 146 //value of wMax on version 8
11178 * }
11179 */
11180
11181
2/2
✓ Branch 0 taken 5256 times.
✓ Branch 1 taken 36 times.
5292 for (int32_t q = 0; q < num_defense; q++)
11182 {
11183
1/2
✓ Branch 0 taken 5256 times.
✗ Branch 1 not taken.
5256 if (!p_getc(&def, f))
11184 return qe_invalid;
11185
11186 5256 hero_defence[q] = def;
11187 5256 }
11188 36 }
11189 else
11190 {
11191 int32_t num_defense = wMax;
11192 for (int32_t q = 0; q < num_defense; q++)
11193 {
11194 hero_defence[q] = 0;
11195 }
11196 }
11197 36 }
11198
11199
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 5 times.
36 if(FFCore.quest_format[vInitData] < 34)
11200 {
11201 5 bool fastswim = zinit.hero_swim_speed > 60;
11202 // '2/3' or '1/2'
11203 5 zinit.hero_swim_mult = fastswim ? 2 : 1;
11204 5 zinit.hero_swim_div = fastswim ? 3 : 2;
11205 5 }
11206 36 return 0;
11207 36 }
11208
11209
11210 113 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11211 {
11212 //these are here to bypass compiler warnings about unused arguments
11213 113 Header=Header;
11214
11215 dword dummy;
11216 113 word s_version=0, s_cversion=0;
11217
11218 //section version info
11219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11220 {
11221 return qe_invalid;
11222 }
11223
11224 113 FFCore.quest_format[vHeroSprites] = s_version;
11225
11226 //al_trace("Player sprites version %d\n", s_version);
11227
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11228 {
11229 return qe_invalid;
11230 }
11231
11232 //section size
11233
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11234 {
11235 return qe_invalid;
11236 }
11237
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if ( s_version >= 6 )
11238 {
11239 //al_trace("Reading Player Sprites v6\n");
11240 36 return readherosprites3(f, s_version, dummy);
11241 }
11242 77 else return readherosprites2(f, s_version, dummy);
11243 113 }
11244
11245 113 int32_t readsubscreens(PACKFILE *f, zquestheader *Header)
11246 {
11247 int32_t dummy;
11248 113 word s_version=0, s_cversion=0;
11249
11250 //section version info
11251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
11252 {
11253 return qe_invalid;
11254 }
11255
11256 113 FFCore.quest_format[vSubscreen] = s_version;
11257
11258 //al_trace("Subscreens version %d\n", s_version);
11259
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
11260 {
11261 return qe_invalid;
11262 }
11263
11264 //section size
11265
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
11266 {
11267 return qe_invalid;
11268 }
11269
11270 //finally... section data
11271
2/2
✓ Branch 0 taken 14464 times.
✓ Branch 1 taken 113 times.
14577 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11272 {
11273 14464 int32_t ret = read_one_subscreen(f, Header, i, s_version, s_cversion);
11274
11275
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(ret!=0) return ret;
11276 14464 }
11277
11278 113 return 0;
11279 113 }
11280
11281 14464 int32_t read_one_subscreen(PACKFILE *f, zquestheader *, int32_t i, word s_version, word)
11282 {
11283 14464 int32_t numsub=0;
11284 14464 byte temp_ss=0;
11285 subscreen_object temp_sub_stack;
11286 14464 subscreen_object *temp_sub = &temp_sub_stack;
11287
11288 char tempname[64];
11289
11290 // FWIW I never saw anything bigger than 20.
11291 #define MAX_DP1_LEN 1024
11292 char tempdp1[MAX_DP1_LEN];
11293
11294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(!pfread(tempname,64,f))
11295 {
11296 return qe_invalid;
11297 }
11298
11299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version > 1)
11300 {
11301
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_getc(&temp_ss,f))
11302 {
11303 return qe_invalid;
11304 }
11305 14464 }
11306
11307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14464 times.
14464 if(s_version < 4)
11308 {
11309 uint8_t tmp=0;
11310
11311 if(!p_getc(&tmp,f))
11312 {
11313 return qe_invalid;
11314 }
11315
11316 numsub = (int32_t)tmp;
11317 }
11318 else
11319 {
11320 word tmp;
11321
11322
1/2
✓ Branch 0 taken 14464 times.
✗ Branch 1 not taken.
14464 if(!p_igetw(&tmp, f))
11323 {
11324 return qe_invalid;
11325 }
11326
11327 14464 numsub = (int32_t)tmp;
11328 }
11329
11330 int32_t j;
11331
11332
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42368 times.
✓ Branch 2 taken 27904 times.
✓ Branch 3 taken 14464 times.
42368 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11333 {
11334 27904 memset(temp_sub,0,sizeof(subscreen_object));
11335
11336
2/2
✓ Branch 0 taken 1214 times.
✓ Branch 1 taken 26690 times.
27904 switch(custom_subscreen[i].objects[j].type)
11337 {
11338 case ssoTEXT:
11339 case ssoTEXTBOX:
11340 case ssoCURRENTITEMTEXT:
11341 case ssoCURRENTITEMCLASSTEXT:
11342
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1214 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1214 times.
1214 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11343
11344 //fall through
11345 default:
11346 27904 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11347 27904 break;
11348 }
11349
11350
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->type),f))
11351 {
11352 return qe_invalid;
11353 }
11354
11355
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->pos),f))
11356 {
11357 return qe_invalid;
11358 }
11359
11360
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(s_version < 5)
11361 {
11362 switch(temp_sub->pos)
11363 {
11364 case 0:
11365 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11366 break;
11367
11368 case 1:
11369 temp_sub->pos = sspUP;
11370 break;
11371
11372 case 2:
11373 temp_sub->pos = sspDOWN;
11374 break;
11375
11376 default:
11377 temp_sub->pos = 0;
11378 }
11379 }
11380
11381
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->x),f))
11382 {
11383 return qe_invalid;
11384 }
11385
11386
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->y),f))
11387 {
11388 return qe_invalid;
11389 }
11390
11391
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->w),f))
11392 {
11393 return qe_invalid;
11394 }
11395
11396
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->h),f))
11397 {
11398 return qe_invalid;
11399 }
11400
11401
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype1),f))
11402 {
11403 return qe_invalid;
11404 }
11405
11406
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color1),f))
11407 {
11408 return qe_invalid;
11409 }
11410
11411
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype2),f))
11412 {
11413 return qe_invalid;
11414 }
11415
11416
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color2),f))
11417 {
11418 return qe_invalid;
11419 }
11420
11421
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->colortype3),f))
11422 {
11423 return qe_invalid;
11424 }
11425
11426
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->color3),f))
11427 {
11428 return qe_invalid;
11429 }
11430
11431
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d1),f))
11432 {
11433 return qe_invalid;
11434 }
11435
11436
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d2),f))
11437 {
11438 return qe_invalid;
11439 }
11440
11441
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d3),f))
11442 {
11443 return qe_invalid;
11444 }
11445
11446
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d4),f))
11447 {
11448 return qe_invalid;
11449 }
11450
11451
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d5),f))
11452 {
11453 return qe_invalid;
11454 }
11455
11456
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d6),f))
11457 {
11458 return qe_invalid;
11459 }
11460
11461
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d7),f))
11462 {
11463 return qe_invalid;
11464 }
11465
11466
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d8),f))
11467 {
11468 return qe_invalid;
11469 }
11470
11471
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d9),f))
11472 {
11473 return qe_invalid;
11474 }
11475
11476
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetd(&(temp_sub->d10),f))
11477 {
11478 return qe_invalid;
11479 }
11480
11481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27904 times.
27904 if(s_version < 2)
11482 {
11483 if(!p_igetl(&(temp_sub->speed),f))
11484 {
11485 return qe_invalid;
11486 }
11487
11488 if(!p_igetl(&(temp_sub->delay),f))
11489 {
11490 return qe_invalid;
11491 }
11492
11493 if(!p_igetl(&(temp_sub->frame),f))
11494 {
11495 return qe_invalid;
11496 }
11497 }
11498 else
11499 {
11500
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->speed),f))
11501 {
11502 return qe_invalid;
11503 }
11504
11505
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_getc(&(temp_sub->delay),f))
11506 {
11507 return qe_invalid;
11508 }
11509
11510
1/2
✓ Branch 0 taken 27904 times.
✗ Branch 1 not taken.
27904 if(!p_igetw(&(temp_sub->frame),f))
11511 {
11512 return qe_invalid;
11513 }
11514 }
11515
11516 27904 int32_t temp_size=0;
11517
11518 // bool deletets = false;
11519
4/4
✓ Branch 0 taken 11658 times.
✓ Branch 1 taken 1977 times.
✓ Branch 2 taken 14118 times.
✓ Branch 3 taken 151 times.
27904 switch(temp_sub->type)
11520 {
11521 case ssoTEXT:
11522 case ssoTEXTBOX:
11523 case ssoCURRENTITEMTEXT:
11524 case ssoCURRENTITEMCLASSTEXT:
11525 {
11526 word temptempsize;
11527
11528
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!p_igetw(&temptempsize,f))
11529 {
11530 return qe_invalid;
11531 }
11532
11533 //temptempsize = temp1 + (temp2 << 8);
11534 1977 temp_size = (int32_t)temptempsize;
11535
11536
11537 1977 uint32_t char_length = temp_size+2;
11538
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if (char_length > MAX_DP1_LEN)
11539 {
11540 return qe_invalid;
11541 }
11542 1977 tempdp1[char_length - 1] = '\0';
11543
11544
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
1977 if(temp_size)
11545 {
11546
1/2
✓ Branch 0 taken 1977 times.
✗ Branch 1 not taken.
1977 if(!pfread(tempdp1,temp_size+1,f))
11547 {
11548 return qe_invalid;
11549 }
11550 1977 }
11551 }
11552 1977 break;
11553
11554 case ssoLIFEMETER:
11555
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11556 temp_sub->d3 = 1;
11557
11558
1/2
✓ Branch 0 taken 151 times.
✗ Branch 1 not taken.
151 if(!p_getc(&(temp_sub->dp1),f))
11559 {
11560 return qe_invalid;
11561 }
11562
11563 151 break;
11564
11565
11566 case ssoCURRENTITEM:
11567
11568
1/2
✓ Branch 0 taken 11658 times.
✗ Branch 1 not taken.
11658 if(s_version < 6)
11569 {
11570 switch(temp_sub->d1)
11571 {
11572 case ssiBOMB:
11573 temp_sub->d1 = itype_bomb;
11574 break;
11575
11576 case ssiSWORD:
11577 temp_sub->d1 = itype_sword;
11578 break;
11579
11580 case ssiSHIELD:
11581 temp_sub->d1 = itype_shield;
11582 break;
11583
11584 case ssiCANDLE:
11585 temp_sub->d1 = itype_candle;
11586 break;
11587
11588 case ssiLETTER:
11589 temp_sub->d1 = itype_letter;
11590 break;
11591
11592 case ssiPOTION:
11593 temp_sub->d1 = itype_potion;
11594 break;
11595
11596 case ssiLETTERPOTION:
11597 temp_sub->d1 = itype_letterpotion;
11598 break;
11599
11600 case ssiBOW:
11601 temp_sub->d1 = itype_bow;
11602 break;
11603
11604 case ssiARROW:
11605 temp_sub->d1 = itype_arrow;
11606 break;
11607
11608 case ssiBOWANDARROW:
11609 temp_sub->d1 = itype_bowandarrow;
11610 break;
11611
11612 case ssiBAIT:
11613 temp_sub->d1 = itype_bait;
11614 break;
11615
11616 case ssiRING:
11617 temp_sub->d1 = itype_ring;
11618 break;
11619
11620 case ssiBRACELET:
11621 temp_sub->d1 = itype_bracelet;
11622 break;
11623
11624 case ssiMAP:
11625 temp_sub->d1 = itype_map;
11626 break;
11627
11628 case ssiCOMPASS:
11629 temp_sub->d1 = itype_compass;
11630 break;
11631
11632 case ssiBOSSKEY:
11633 temp_sub->d1 = itype_bosskey;
11634 break;
11635
11636 case ssiMAGICKEY:
11637 temp_sub->d1 = itype_magickey;
11638 break;
11639
11640 case ssiBRANG:
11641 temp_sub->d1 = itype_brang;
11642 break;
11643
11644 case ssiWAND:
11645 temp_sub->d1 = itype_wand;
11646 break;
11647
11648 case ssiRAFT:
11649 temp_sub->d1 = itype_raft;
11650 break;
11651
11652 case ssiLADDER:
11653 temp_sub->d1 = itype_ladder;
11654 break;
11655
11656 case ssiWHISTLE:
11657 temp_sub->d1 = itype_whistle;
11658 break;
11659
11660 case ssiBOOK:
11661 temp_sub->d1 = itype_book;
11662 break;
11663
11664 case ssiWALLET:
11665 temp_sub->d1 = itype_wallet;
11666 break;
11667
11668 case ssiSBOMB:
11669 temp_sub->d1 = itype_sbomb;
11670 break;
11671
11672 case ssiHCPIECE:
11673 temp_sub->d1 = itype_heartpiece;
11674 break;
11675
11676 case ssiAMULET:
11677 temp_sub->d1 = itype_amulet;
11678 break;
11679
11680 case ssiFLIPPERS:
11681 temp_sub->d1 = itype_flippers;
11682 break;
11683
11684 case ssiHOOKSHOT:
11685 temp_sub->d1 = itype_hookshot;
11686 break;
11687
11688 case ssiLENS:
11689 temp_sub->d1 = itype_lens;
11690 break;
11691
11692 case ssiHAMMER:
11693 temp_sub->d1 = itype_hammer;
11694 break;
11695
11696 case ssiBOOTS:
11697 temp_sub->d1 = itype_boots;
11698 break;
11699
11700 case ssiDIVINEFIRE:
11701 temp_sub->d1 = itype_divinefire;
11702 break;
11703
11704 case ssiDIVINEESCAPE:
11705 temp_sub->d1 = itype_divineescape;
11706 break;
11707
11708 case ssiDIVINEPROTECTION:
11709 temp_sub->d1 = itype_divineprotection;
11710 break;
11711
11712 case ssiQUIVER:
11713 temp_sub->d1 = itype_quiver;
11714 break;
11715
11716 case ssiBOMBBAG:
11717 temp_sub->d1 = itype_bombbag;
11718 break;
11719
11720 case ssiCBYRNA:
11721 temp_sub->d1 = itype_cbyrna;
11722 break;
11723
11724 case ssiROCS:
11725 temp_sub->d1 = itype_rocs;
11726 break;
11727
11728 case ssiHOVERBOOTS:
11729 temp_sub->d1 = itype_hoverboots;
11730 break;
11731
11732 case ssiSPINSCROLL:
11733 temp_sub->d1 = itype_spinscroll;
11734 break;
11735
11736 case ssiCROSSSCROLL:
11737 temp_sub->d1 = itype_crossscroll;
11738 break;
11739
11740 case ssiQUAKESCROLL:
11741 temp_sub->d1 = itype_quakescroll;
11742 break;
11743
11744 case ssiWHISPRING:
11745 temp_sub->d1 = itype_whispring;
11746 break;
11747
11748 case ssiCHARGERING:
11749 temp_sub->d1 = itype_chargering;
11750 break;
11751
11752 case ssiPERILSCROLL:
11753 temp_sub->d1 = itype_perilscroll;
11754 break;
11755
11756 case ssiWEALTHMEDAL:
11757 temp_sub->d1 = itype_wealthmedal;
11758 break;
11759
11760 case ssiHEARTRING:
11761 temp_sub->d1 = itype_heartring;
11762 break;
11763
11764 case ssiMAGICRING:
11765 temp_sub->d1 = itype_magicring;
11766 break;
11767
11768 case ssiSPINSCROLL2:
11769 temp_sub->d1 = itype_spinscroll2;
11770 break;
11771
11772 case ssiQUAKESCROLL2:
11773 temp_sub->d1 = itype_quakescroll2;
11774 break;
11775
11776 case ssiAGONY:
11777 temp_sub->d1 = itype_agony;
11778 break;
11779
11780 case ssiSTOMPBOOTS:
11781 temp_sub->d1 = itype_stompboots;
11782 break;
11783
11784 case ssiWHIMSICALRING:
11785 temp_sub->d1 = itype_whimsicalring;
11786 break;
11787
11788 case ssiPERILRING:
11789 temp_sub->d1 = itype_perilring;
11790 break;
11791
11792 default:
11793 temp_sub->d1 += itype_custom1 - ssiMAX;
11794 }
11795 }
11796
11797 //fall-through
11798 default:
11799
1/2
✓ Branch 0 taken 25776 times.
✗ Branch 1 not taken.
25776 if(!p_getc(&(temp_sub->dp1),f))
11800 {
11801 return qe_invalid;
11802 }
11803
11804 25776 break;
11805 }
11806
11807
2/2
✓ Branch 0 taken 19220 times.
✓ Branch 1 taken 8684 times.
27904 if(s_version < 7)
11808 {
11809
3/3
✓ Branch 0 taken 8025 times.
✓ Branch 1 taken 227 times.
✓ Branch 2 taken 432 times.
8684 switch(temp_sub->type)
11810 {
11811 case ssoMAGICGAUGE:
11812 {
11813
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 192 times.
227 if(!temp_sub->d9)
11814 192 temp_sub->d9 = -1; //-1 now represents 'always'
11815 227 break;
11816 }
11817 case ssoLIFEGAUGE:
11818 432 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11819 432 break;
11820 }
11821 8684 }
11822
11823
3/3
✓ Branch 0 taken 1977 times.
✓ Branch 1 taken 24660 times.
✓ Branch 2 taken 1267 times.
27904 switch(temp_sub->type)
11824 {
11825 case ssoTEXT:
11826 case ssoTEXTBOX:
11827 case ssoCURRENTITEMTEXT:
11828 case ssoCURRENTITEMCLASSTEXT:
11829
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1977 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1977 if(custom_subscreen[i].objects[j].dp1 != NULL) delete[](char *)custom_subscreen[i].objects[j].dp1;
11830
11831 1977 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11832 1977 custom_subscreen[i].objects[j].dp1 = NULL;
11833 1977 custom_subscreen[i].objects[j].dp1 = new char[temp_size+2];
11834 1977 strcpy((char*)custom_subscreen[i].objects[j].dp1,tempdp1);
11835 1977 break;
11836
11837 case ssoCOUNTER:
11838
1/2
✓ Branch 0 taken 1267 times.
✗ Branch 1 not taken.
1267 if(s_version<3)
11839 {
11840 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11841 temp_sub->d8=0;
11842 }
11843
11844 default:
11845 25927 memcpy(&custom_subscreen[i].objects[j],temp_sub,sizeof(subscreen_object));
11846 25927 break;
11847 }
11848
11849 27904 custom_subscreen[i].name[0] = '\0';
11850 27904 strncat(custom_subscreen[i].name, tempname, 64 - 1);
11851 27904 custom_subscreen[i].ss_type = temp_ss;
11852 27904 }
11853
11854
2/2
✓ Branch 0 taken 3674880 times.
✓ Branch 1 taken 14464 times.
3689344 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11855 {
11856 //clear all unused object in this subscreen -DD
11857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3674880 times.
3674880 switch(custom_subscreen[i].objects[j].type)
11858 {
11859 case ssoTEXT:
11860 case ssoTEXTBOX:
11861 case ssoCURRENTITEMTEXT:
11862 case ssoCURRENTITEMCLASSTEXT:
11863 if(custom_subscreen[i].objects[j].dp1 != NULL) delete [](char *)custom_subscreen[i].objects[j].dp1;
11864
11865 //fall through
11866 default:
11867 3674880 memset(&custom_subscreen[i].objects[j],0,sizeof(subscreen_object));
11868 3674880 break;
11869 }
11870 3674880 }
11871
11872 14464 return 0;
11873 14464 }
11874
11875 3968 void reset_subscreen(subscreen_group *tempss)
11876 {
11877
2/2
✓ Branch 0 taken 1015808 times.
✓ Branch 1 taken 3968 times.
1019776 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11878 {
11879
2/2
✓ Branch 0 taken 205 times.
✓ Branch 1 taken 1015603 times.
1015808 switch(tempss->objects[i].type)
11880 {
11881 case ssoTEXT:
11882 case ssoTEXTBOX:
11883 case ssoCURRENTITEMTEXT:
11884 case ssoCURRENTITEMCLASSTEXT:
11885
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 205 times.
✓ Branch 2 taken 205 times.
✗ Branch 3 not taken.
205 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11886
11887 //fall through
11888 default:
11889 1015808 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11890 1015808 break;
11891 }
11892 1015808 }
11893 3968 }
11894
11895 31 void reset_subscreens()
11896 {
11897
2/2
✓ Branch 0 taken 3968 times.
✓ Branch 1 taken 31 times.
3999 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; ++i)
11898 {
11899 3968 reset_subscreen(&custom_subscreen[i]);
11900 3968 }
11901 31 }
11902
11903 31 int32_t setupsubscreens()
11904 {
11905 31 reset_subscreens();
11906 31 int32_t tempsubscreen=zinit.subscreen;
11907 subscreen_object *tempsub;
11908
11909
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(tempsubscreen>=ssdtMAX)
11910 {
11911 tempsubscreen=0;
11912 }
11913
11914
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 switch(tempsubscreen)
11915 {
11916 case ssdtOLD:
11917 case ssdtNEWSUBSCR:
11918 case ssdtREV2:
11919 case ssdtBSZELDA:
11920 case ssdtBSZELDAMODIFIED:
11921 case ssdtBSZELDAENHANCED:
11922 case ssdtBSZELDACOMPLETE:
11923 {
11924 31 tempsub = default_subscreen_active[tempsubscreen][0];
11925 int32_t i;
11926
11927
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11928 {
11929
2/3
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 1933 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11930 {
11931 case ssoTEXT:
11932 case ssoTEXTBOX:
11933 case ssoCURRENTITEMTEXT:
11934 case ssoCURRENTITEMCLASSTEXT:
11935
1/4
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
82 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
11936
11937 82 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11938 82 custom_subscreen[0].objects[i].dp1 = NULL;
11939 82 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11940 82 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
11941 82 break;
11942
11943 case ssoLIFEMETER:
11944 {
11945 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11946
11947 if(get_bit(deprecated_rules, 12) != 0)
11948 custom_subscreen[0].objects[i].d3=1;
11949 else
11950 custom_subscreen[0].objects[i].d3=0;
11951
11952 break;
11953 }
11954 /*
11955 case ssoTRIFRAME:
11956 {
11957 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11958 custom_subscreen[0].objects[i].d1 = 8594;
11959 custom_subscreen[0].objects[i].d2 = 8;
11960 custom_subscreen[0].objects[i].d3 = 8771;
11961 custom_subscreen[0].objects[i].d4 = 8;
11962 custom_subscreen[0].objects[i].d5 = 1;
11963 custom_subscreen[0].objects[i].d6 = 1;
11964 break;
11965 }*/
11966
11967 default:
11968 1933 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
11969 1933 break;
11970 }
11971 2015 }
11972
11973 31 custom_subscreen[0].ss_type=sstACTIVE;
11974 31 sprintf(custom_subscreen[0].name, "Active Subscreen (Triforce)");
11975 31 tempsub = default_subscreen_active[tempsubscreen][1];
11976
11977
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2046 times.
✓ Branch 2 taken 2015 times.
✓ Branch 3 taken 31 times.
2046 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
11978 {
11979
2/3
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 1920 times.
✗ Branch 2 not taken.
2015 switch(tempsub[i].type)
11980 {
11981 case ssoTEXT:
11982 case ssoTEXTBOX:
11983 case ssoCURRENTITEMTEXT:
11984 case ssoCURRENTITEMCLASSTEXT:
11985
1/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
95 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
11986
11987 95 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11988 95 custom_subscreen[1].objects[i].dp1 = NULL;
11989 95 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
11990 95 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
11991 95 break;
11992
11993 case ssoLIFEMETER:
11994 {
11995 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
11996
11997 if(get_bit(deprecated_rules, 12) != 0)
11998 custom_subscreen[1].objects[i].d3=1;
11999 else
12000 custom_subscreen[1].objects[i].d3=0;
12001
12002 break;
12003 }
12004 /*
12005 case ssoTRIFRAME:
12006 {
12007 custom_subscreen[1].objects[i].d1 = 8594;
12008 custom_subscreen[1].objects[i].d2 = 8;
12009 custom_subscreen[1].objects[i].d3 = 8771;
12010 custom_subscreen[1].objects[i].d4 = 8;
12011 custom_subscreen[1].objects[i].d5 = 1;
12012 custom_subscreen[1].objects[i].d6 = 1;
12013 break;
12014 }*/
12015
12016 default:
12017 1920 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12018 1920 break;
12019 }
12020 2015 }
12021
12022 31 custom_subscreen[1].ss_type=sstACTIVE;
12023 31 sprintf(custom_subscreen[1].name, "Active Subscreen (Dungeon Map)");
12024 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12025 31 tempsub = default_subscreen_passive[tempsubscreen][0];
12026
12027
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 651 times.
✓ Branch 2 taken 620 times.
✓ Branch 3 taken 31 times.
651 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12028 {
12029
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 496 times.
✓ Branch 2 taken 31 times.
620 switch(tempsub[i].type)
12030 {
12031 case ssoTEXT:
12032 case ssoTEXTBOX:
12033 case ssoCURRENTITEMTEXT:
12034 case ssoCURRENTITEMCLASSTEXT:
12035
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12036
12037 93 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12038 93 custom_subscreen[2].objects[i].dp1 = NULL;
12039 93 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12040 93 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12041 93 break;
12042
12043 case ssoLIFEMETER:
12044 {
12045 31 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12046
12047
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12048 14 custom_subscreen[2].objects[i].d3=1;
12049 else
12050 17 custom_subscreen[2].objects[i].d3=0;
12051
12052 31 break;
12053 }
12054
12055 default:
12056 496 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12057 496 break;
12058 }
12059 620 }
12060
12061 31 custom_subscreen[2].ss_type=sstPASSIVE;
12062 31 sprintf(custom_subscreen[2].name, "Passive Subscreen (Magic)");
12063 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12064 31 tempsub = default_subscreen_passive[tempsubscreen][1];
12065
12066
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 620 times.
✓ Branch 2 taken 589 times.
✓ Branch 3 taken 31 times.
620 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12067 {
12068
3/3
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 465 times.
✓ Branch 2 taken 31 times.
589 switch(tempsub[i].type)
12069 {
12070 case ssoTEXT:
12071 case ssoTEXTBOX:
12072 case ssoCURRENTITEMTEXT:
12073 case ssoCURRENTITEMCLASSTEXT:
12074
1/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
93 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12075
12076 93 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12077 93 custom_subscreen[3].objects[i].dp1 = NULL;
12078 93 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12079 93 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12080 93 break;
12081
12082 case ssoLIFEMETER:
12083 {
12084 31 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12085
12086
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 17 times.
31 if(get_bit(deprecated_rules, 12) != 0)
12087 14 custom_subscreen[3].objects[i].d3=1;
12088 else
12089 17 custom_subscreen[3].objects[i].d3=0;
12090
12091 31 break;
12092 }
12093
12094 default:
12095 465 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12096 465 break;
12097 }
12098 589 }
12099
12100 31 custom_subscreen[3].ss_type=sstPASSIVE;
12101 31 sprintf(custom_subscreen[3].name, "Passive Subscreen (No Magic)");
12102 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12103 31 break;
12104 }
12105
12106 case ssdtZ3:
12107 {
12108 tempsub = z3_active_a;
12109 int32_t i;
12110
12111 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12112 {
12113 switch(tempsub[i].type)
12114 {
12115 case ssoTEXT:
12116 case ssoTEXTBOX:
12117 case ssoCURRENTITEMTEXT:
12118 case ssoCURRENTITEMCLASSTEXT:
12119 if(custom_subscreen[0].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[0].objects[i].dp1;
12120
12121 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12122 custom_subscreen[0].objects[i].dp1 = NULL;
12123 custom_subscreen[0].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12124 strcpy((char*)custom_subscreen[0].objects[i].dp1,(char*)tempsub[i].dp1);
12125 break;
12126
12127 case ssoLIFEMETER:
12128 {
12129 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12130
12131 if(get_bit(deprecated_rules, 12) != 0)
12132 custom_subscreen[0].objects[i].d3=1;
12133 else
12134 custom_subscreen[0].objects[i].d3=0;
12135
12136 break;
12137 }
12138
12139 default:
12140 memcpy(&custom_subscreen[0].objects[i],&tempsub[i],sizeof(subscreen_object));
12141 break;
12142 }
12143 }
12144
12145 custom_subscreen[0].ss_type=sstACTIVE;
12146 // memset(&custom_subscreen[0].objects[i],0,sizeof(subscreen_object));
12147 tempsub = z3_active_ab;
12148
12149 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12150 {
12151 switch(tempsub[i].type)
12152 {
12153 case ssoTEXT:
12154 case ssoTEXTBOX:
12155 case ssoCURRENTITEMTEXT:
12156 case ssoCURRENTITEMCLASSTEXT:
12157 if(custom_subscreen[1].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[1].objects[i].dp1;
12158
12159 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12160 custom_subscreen[1].objects[i].dp1 = NULL;
12161 custom_subscreen[1].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12162 strcpy((char*)custom_subscreen[1].objects[i].dp1,(char*)tempsub[i].dp1);
12163 break;
12164
12165 case ssoLIFEMETER:
12166 {
12167 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12168
12169 if(get_bit(deprecated_rules, 12) != 0)
12170 custom_subscreen[1].objects[i].d3=1;
12171 else
12172 custom_subscreen[1].objects[i].d3=0;
12173
12174 break;
12175 }
12176
12177 default:
12178 memcpy(&custom_subscreen[1].objects[i],&tempsub[i],sizeof(subscreen_object));
12179 break;
12180 }
12181 }
12182
12183 custom_subscreen[1].ss_type=sstACTIVE;
12184 // memset(&custom_subscreen[1].objects[i],0,sizeof(subscreen_object));
12185 tempsub = z3_passive_a;
12186
12187 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12188 {
12189 switch(tempsub[i].type)
12190 {
12191 case ssoTEXT:
12192 case ssoTEXTBOX:
12193 case ssoCURRENTITEMTEXT:
12194 case ssoCURRENTITEMCLASSTEXT:
12195 if(custom_subscreen[2].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[2].objects[i].dp1;
12196
12197 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12198 custom_subscreen[2].objects[i].dp1 = NULL;
12199 custom_subscreen[2].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12200 strcpy((char*)custom_subscreen[2].objects[i].dp1,(char*)tempsub[i].dp1);
12201 break;
12202
12203 case ssoLIFEMETER:
12204 {
12205 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12206
12207 if(get_bit(deprecated_rules, 12) != 0)
12208 custom_subscreen[2].objects[i].d3=1;
12209 else
12210 custom_subscreen[2].objects[i].d3=0;
12211
12212 break;
12213 }
12214
12215 default:
12216 memcpy(&custom_subscreen[2].objects[i],&tempsub[i],sizeof(subscreen_object));
12217 break;
12218 }
12219 }
12220
12221 custom_subscreen[2].ss_type=sstPASSIVE;
12222 // memset(&custom_subscreen[2].objects[i],0,sizeof(subscreen_object));
12223 tempsub = z3_passive_ab;
12224
12225 for(i=0; (i<MAXSUBSCREENITEMS&&tempsub[i].type!=ssoNULL); i++)
12226 {
12227 switch(tempsub[i].type)
12228 {
12229 case ssoTEXT:
12230 case ssoTEXTBOX:
12231 case ssoCURRENTITEMTEXT:
12232 case ssoCURRENTITEMCLASSTEXT:
12233 if(custom_subscreen[3].objects[i].dp1 != NULL) delete [](char *)custom_subscreen[3].objects[i].dp1;
12234
12235 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12236 custom_subscreen[3].objects[i].dp1 = NULL;
12237 custom_subscreen[3].objects[i].dp1 = new char[strlen((char*)tempsub[i].dp1)+1];
12238 strcpy((char*)custom_subscreen[3].objects[i].dp1,(char*)tempsub[i].dp1);
12239 break;
12240
12241 case ssoLIFEMETER:
12242 {
12243 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12244
12245 if(get_bit(deprecated_rules, 12) != 0)
12246 custom_subscreen[3].objects[i].d3=1;
12247 else
12248 custom_subscreen[3].objects[i].d3=0;
12249
12250 break;
12251 }
12252
12253 default:
12254 memcpy(&custom_subscreen[3].objects[i],&tempsub[i],sizeof(subscreen_object));
12255 break;
12256 }
12257 }
12258
12259 custom_subscreen[3].ss_type=sstPASSIVE;
12260 // memset(&custom_subscreen[3].objects[i],0,sizeof(subscreen_object));
12261 break;
12262 }
12263 }
12264
12265
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 124 times.
155 for(int32_t i=0; i<4; ++i)
12266 {
12267 124 purge_blank_subscreen_objects(&custom_subscreen[i]);
12268 124 }
12269
12270 31 return 0;
12271 }
12272
12273 extern script_data *ffscripts[NUMSCRIPTFFC];
12274 extern script_data *itemscripts[NUMSCRIPTITEM];
12275 extern script_data *guyscripts[NUMSCRIPTGUYS];
12276 extern script_data *wpnscripts[NUMSCRIPTWEAPONS];
12277 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
12278 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
12279 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
12280 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
12281 extern script_data *playerscripts[NUMSCRIPTPLAYER];
12282 extern script_data *screenscripts[NUMSCRIPTSCREEN];
12283 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
12284 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
12285 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
12286 //script_data *wpnscripts[NUMSCRIPTWEAPONS]; //used only for old data
12287
12288
12289
12290 115 int32_t readffscript(PACKFILE *f, zquestheader *Header)
12291 {
12292 int32_t dummy;
12293 115 word s_version=0, s_cversion=0, zmeta_version=0;
12294 115 byte numscripts=0;
12295 115 numscripts=numscripts; //to avoid unused variables warnings
12296 int32_t ret;
12297
12298 //section version info
12299
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115 times.
115 if(!p_igetw(&s_version,f))
12300 {
12301 return qe_invalid;
12302 }
12303
12304 115 FFCore.quest_format[vFFScript] = s_version;
12305
12306
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetw(&s_cversion,f))
12307 {
12308 return qe_invalid;
12309 }
12310
12311
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 36 times.
115 if(s_version >= 18)
12312 {
12313
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&zmeta_version,f))
12314 {
12315 return qe_invalid;
12316 }
12317 36 }
12318
12319 //al_trace("Scripts version %d\n", s_version);
12320 //section size
12321
1/2
✓ Branch 0 taken 115 times.
✗ Branch 1 not taken.
115 if(!p_igetl(&dummy,f))
12322 {
12323 return qe_invalid;
12324 }
12325
12326 //ZScriptVersion::setVersion(s_version); ~this ideally, but there's no ZC/ZQuest defines...
12327 115 setZScriptVersion(s_version); //Lumped in zelda.cpp and in zquest.cpp as zquest can't link ZScriptVersion
12328 115 temp_ffscript_version = s_version;
12329 //miscQdata *the_misc;
12330
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 77 times.
115 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
12331 115 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
12332
12333 //finally... section data
12334
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 103 times.
57971 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
12335 {
12336 57856 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
12337
12338
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if (ret)
12339 {
12340 return qe_invalid;
12341 }
12342 57856 }
12343
12344 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
12345 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
12346 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
12347 * there was a version bump a week before a change that broke stuff.
12348 */
12349
7/8
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 67 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✓ Branch 4 taken 36 times.
✓ Branch 5 taken 36 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 36 times.
103 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
12350 {
12351 139 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
12352 139 }
12353
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version < 19)
12354 {
12355 77 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
12356 77 }
12357
12358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 1)
12359 {
12360
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
12361 {
12362 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
12363
12364
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12365 {
12366 return qe_invalid;
12367 }
12368 28928 }
12369
12370
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12371 {
12372 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12373
12374
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12375 {
12376 return qe_invalid;
12377 }
12378 28928 }
12379
12380
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12381 {
12382 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &wpnscripts[i], zmeta_version);
12383
12384
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12385 {
12386 return qe_invalid;
12387 }
12388 28928 }
12389
12390
12391
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12392 {
12393 28928 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12394
12395
1/2
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
28928 if (ret)
12396 {
12397 return qe_invalid;
12398 }
12399 28928 }
12400
12401
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 16)
12402 {
12403
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 36 times.
324 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12404 {
12405 288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12406
12407
1/2
✓ Branch 0 taken 288 times.
✗ Branch 1 not taken.
288 if (ret)
12408 {
12409 return qe_invalid;
12410 }
12411 288 }
12412 36 }
12413
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 else if(s_version > 13)
12414 {
12415 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12416 {
12417 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12418
12419 if (ret)
12420 {
12421 return qe_invalid;
12422 }
12423 }
12424
12425 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12426 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12427
12428 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12429 }
12430
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 else if(s_version > 4)
12431 {
12432
2/2
✓ Branch 0 taken 308 times.
✓ Branch 1 taken 77 times.
385 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12433 {
12434 308 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12435
12436
1/2
✓ Branch 0 taken 308 times.
✗ Branch 1 not taken.
308 if (ret)
12437 {
12438 return qe_invalid;
12439 }
12440 308 }
12441
12442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12443
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12444
12445
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12446
12447
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12448
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12449
12450
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12451
12452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12453
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_F6];
12454
12455
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12456
12457
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12458
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12459
12460
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12461 77 }
12462 else
12463 {
12464 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12465 {
12466 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12467
12468 if (ret)
12469 {
12470 return qe_invalid;
12471 }
12472 }
12473
12474 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12475 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12476
12477 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data();
12478
12479 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12480 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12481
12482 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data();
12483
12484 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12485 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12486
12487 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data();
12488
12489 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12490 delete globalscripts[GLOBAL_SCRIPT_F6];
12491
12492 globalscripts[GLOBAL_SCRIPT_F6] = new script_data();
12493
12494 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12495 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12496
12497 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data();
12498 }
12499
12500
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(s_version > 10) //expanded the number of Player scripts to 5.
12501 {
12502
2/2
✓ Branch 0 taken 180 times.
✓ Branch 1 taken 36 times.
216 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12503 {
12504 180 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12505
12506
1/2
✓ Branch 0 taken 180 times.
✗ Branch 1 not taken.
180 if (ret)
12507 {
12508 return qe_invalid;
12509 }
12510 180 }
12511 36 }
12512 else
12513 {
12514
2/2
✓ Branch 0 taken 231 times.
✓ Branch 1 taken 77 times.
308 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12515 {
12516 231 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12517
12518
1/2
✓ Branch 0 taken 231 times.
✗ Branch 1 not taken.
231 if (ret)
12519 {
12520 return qe_invalid;
12521 }
12522 231 }
12523
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[3] != NULL)
12524
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 delete playerscripts[3];
12525
12526
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[3] = new script_data();
12527
12528
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 if(playerscripts[4] != NULL)
12529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77 times.
77 delete playerscripts[4];
12530
12531
1/2
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
77 playerscripts[4] = new script_data();
12532 }
12533
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
113 if(s_version > 8 && s_version < 10)
12534 {
12535
12536 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12537 {
12538 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12539
12540 if (ret)
12541 {
12542 return qe_invalid;
12543 }
12544 }
12545 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12546 {
12547 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12548
12549 if (ret)
12550 {
12551 return qe_invalid;
12552 }
12553 }
12554
12555 }
12556
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 10)
12557 {
12558
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12559 {
12560 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12561
12562
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12563 {
12564 return qe_invalid;
12565 }
12566 9216 }
12567
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12568 {
12569 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12570
12571
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12572 {
12573 return qe_invalid;
12574 }
12575 9216 }
12576
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12577 {
12578 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12579
12580
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12581 {
12582 return qe_invalid;
12583 }
12584 9216 }
12585
12586 36 }
12587
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=12)
12588 {
12589
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 36 times.
9252 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12590 {
12591 9216 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12592
12593
1/2
✓ Branch 0 taken 9216 times.
✗ Branch 1 not taken.
9216 if (ret)
12594 {
12595 return qe_invalid;
12596 }
12597 9216 }
12598 36 }
12599
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >=15)
12600 {
12601
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12602 {
12603 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12604
12605
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12606 {
12607 return qe_invalid;
12608 }
12609 18432 }
12610 36 }
12611
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >19)
12612 {
12613 36 word numgenscripts = NUMSCRIPTSGENERIC;
12614
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetw(&numgenscripts,f))
12615 {
12616 return qe_invalid;
12617 }
12618
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 36 times.
18468 for(int32_t i = 0; i < numgenscripts; i++)
12619 {
12620 18432 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12621
12622
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if (ret)
12623 {
12624 return qe_invalid;
12625 }
12626 18432 }
12627 36 }
12628
12629 /*
12630 else //Is this trip really necessary?
12631 {
12632 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12633 {
12634
12635 ewpnscripts[i] = NULL;
12636 }
12637 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12638 {
12639 dmapscripts[i] = NULL;
12640 }
12641 }
12642 */
12643
12644 113 }
12645
12646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 2)
12647 {
12648 int32_t bufsize;
12649 113 p_igetl(&bufsize, f);
12650
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
113 if (bufsize < 0 || bufsize > 1024*1024*10)
12651 {
12652 // God help anyone storing more than 10MB of code in the script buffer.
12653 return qe_invalid;
12654 }
12655 113 char * buf = new char[bufsize+1];
12656 113 pfread(buf, bufsize, f);
12657 113 buf[bufsize]=0;
12658
12659
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 zScript = string(buf);
12660
12661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 delete[] buf;
12662 word numffcbindings;
12663 113 p_igetw(&numffcbindings, f);
12664
12665
2/2
✓ Branch 0 taken 1579 times.
✓ Branch 1 taken 113 times.
1692 for(int32_t i=0; i<numffcbindings; i++)
12666 {
12667 word id;
12668 1579 p_igetw(&id, f);
12669 1579 p_igetl(&bufsize, f);
12670
2/4
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1579 times.
1579 if (bufsize < 0 || bufsize > 1024)
12671 return qe_invalid;
12672 1579 buf = new char[bufsize+1];
12673 1579 pfread(buf, bufsize, f);
12674 1579 buf[bufsize]=0;
12675
12676 //fix for buggy older saved quests -DD
12677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1579 times.
1579 if(id < NUMSCRIPTFFC-1)
12678 1579 ffcmap[id].scriptname = buf;
12679
12680
1/2
✓ Branch 0 taken 1579 times.
✗ Branch 1 not taken.
1579 delete[] buf;
12681 1579 }
12682
12683 word numglobalbindings;
12684 113 p_igetw(&numglobalbindings, f);
12685
12686
2/2
✓ Branch 0 taken 437 times.
✓ Branch 1 taken 113 times.
550 for(int32_t i=0; i<numglobalbindings; i++)
12687 {
12688 word id;
12689 437 p_igetw(&id, f);
12690 437 p_igetl(&bufsize, f);
12691
2/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 437 times.
✗ Branch 3 not taken.
437 if (bufsize < 0 || bufsize > 1024)
12692 return qe_invalid;
12693 437 buf = new char[bufsize+1];
12694 437 pfread(buf, bufsize, f);
12695 437 buf[bufsize]=0;
12696
12697 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12698 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12699 // Ignore these. -DD
12700
3/4
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 159 times.
✓ Branch 3 taken 278 times.
437 if(id >= 0 && id < NUMSCRIPTGLOBAL)
12701 {
12702 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12703
1/2
✓ Branch 0 taken 278 times.
✗ Branch 1 not taken.
278 if(strcmp(buf,"~Continue") == 0)
12704 {
12705 globalmap[id].scriptname = "";
12706
12707 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12708 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12709 }
12710 else
12711 {
12712 278 globalmap[id].scriptname = buf;
12713 }
12714 278 }
12715
12716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 delete[] buf;
12717 437 }
12718
12719
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version > 3)
12720 {
12721 word numitembindings;
12722 113 p_igetw(&numitembindings, f);
12723
12724
2/2
✓ Branch 0 taken 98 times.
✓ Branch 1 taken 113 times.
211 for(int32_t i=0; i<numitembindings; i++)
12725 {
12726 word id;
12727 98 p_igetw(&id, f);
12728 98 p_igetl(&bufsize, f);
12729
2/4
✓ Branch 0 taken 98 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 98 times.
✗ Branch 3 not taken.
98 if (bufsize < 0 || bufsize > 1024)
12730 return qe_invalid;
12731 98 buf = new char[bufsize+1];
12732 98 pfread(buf, bufsize, f);
12733 98 buf[bufsize]=0;
12734
12735 //fix this too
12736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 if(id <NUMSCRIPTITEM-1)
12737 98 itemmap[id].scriptname = buf;
12738
12739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
98 delete[] buf;
12740 98 }
12741 113 }
12742 //(v9+)
12743
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 8)
12744 {
12745 //npc scripts
12746 word numnpcbindings;
12747 36 p_igetw(&numnpcbindings, f);
12748
12749
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 36 times.
48 for(int32_t i=0; i<numnpcbindings; i++)
12750 {
12751 word id;
12752 12 p_igetw(&id, f);
12753 12 p_igetl(&bufsize, f);
12754
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if (bufsize < 0 || bufsize > 1024)
12755 return qe_invalid;
12756 12 buf = new char[bufsize+1];
12757 12 pfread(buf, bufsize, f);
12758 12 buf[bufsize]=0;
12759
12760 //fix this too
12761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(id <NUMSCRIPTGUYS-1)
12762 12 npcmap[id].scriptname = buf;
12763
12764
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 delete[] buf;
12765 12 }
12766 //lweapon
12767 word numlwpnbindings;
12768 36 p_igetw(&numlwpnbindings, f);
12769
12770
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 36 times.
78 for(int32_t i=0; i<numlwpnbindings; i++)
12771 {
12772 word id;
12773 42 p_igetw(&id, f);
12774 42 p_igetl(&bufsize, f);
12775
2/4
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 42 times.
42 if (bufsize < 0 || bufsize > 1024)
12776 return qe_invalid;
12777 42 buf = new char[bufsize+1];
12778 42 pfread(buf, bufsize, f);
12779 42 buf[bufsize]=0;
12780
12781 //fix this too
12782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42 times.
42 if(id <NUMSCRIPTWEAPONS-1)
12783 42 lwpnmap[id].scriptname = buf;
12784
12785
1/2
✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
42 delete[] buf;
12786 42 }
12787 //eweapon
12788 word numewpnbindings;
12789 36 p_igetw(&numewpnbindings, f);
12790
12791
2/2
✓ Branch 0 taken 63 times.
✓ Branch 1 taken 36 times.
99 for(int32_t i=0; i<numewpnbindings; i++)
12792 {
12793 word id;
12794 63 p_igetw(&id, f);
12795 63 p_igetl(&bufsize, f);
12796
2/4
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 63 times.
✗ Branch 3 not taken.
63 if (bufsize < 0 || bufsize > 1024)
12797 return qe_invalid;
12798 63 buf = new char[bufsize+1];
12799 63 pfread(buf, bufsize, f);
12800 63 buf[bufsize]=0;
12801
12802 //fix this too
12803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(id <NUMSCRIPTWEAPONS-1)
12804 63 ewpnmap[id].scriptname = buf;
12805
12806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 delete[] buf;
12807 63 }
12808 //hero
12809 word numherobindings;
12810 36 p_igetw(&numherobindings, f);
12811
12812
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 36 times.
41 for(int32_t i=0; i<numherobindings; i++)
12813 {
12814 word id;
12815 5 p_igetw(&id, f);
12816 5 p_igetl(&bufsize, f);
12817
2/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
5 if (bufsize < 0 || bufsize > 1024)
12818 return qe_invalid;
12819 5 buf = new char[bufsize+1];
12820 5 pfread(buf, bufsize, f);
12821 5 buf[bufsize]=0;
12822
12823 //fix this too
12824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 if(id <NUMSCRIPTPLAYER-1)
12825 5 playermap[id].scriptname = buf;
12826
12827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5 times.
5 delete[] buf;
12828 5 }
12829 //dmaps
12830 word numdmapbindings;
12831 36 p_igetw(&numdmapbindings, f);
12832
12833
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 36 times.
69 for(int32_t i=0; i<numdmapbindings; i++)
12834 {
12835 word id;
12836 33 p_igetw(&id, f);
12837 33 p_igetl(&bufsize, f);
12838
2/4
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
33 if (bufsize < 0 || bufsize > 1024)
12839 return qe_invalid;
12840 33 buf = new char[bufsize+1];
12841 33 pfread(buf, bufsize, f);
12842 33 buf[bufsize]=0;
12843
12844 //fix this too
12845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(id <NUMSCRIPTSDMAP-1)
12846 33 dmapmap[id].scriptname = buf;
12847
12848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 delete[] buf;
12849 33 }
12850 //screen
12851 word numscreenbindings;
12852 36 p_igetw(&numscreenbindings, f);
12853
12854
2/2
✓ Branch 0 taken 37 times.
✓ Branch 1 taken 36 times.
73 for(int32_t i=0; i<numscreenbindings; i++)
12855 {
12856 word id;
12857 37 p_igetw(&id, f);
12858 37 p_igetl(&bufsize, f);
12859
2/4
✓ Branch 0 taken 37 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 37 times.
✗ Branch 3 not taken.
37 if (bufsize < 0 || bufsize > 1024)
12860 return qe_invalid;
12861 37 buf = new char[bufsize+1];
12862 37 pfread(buf, bufsize, f);
12863 37 buf[bufsize]=0;
12864
12865 //fix this too
12866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 if(id <NUMSCRIPTSDMAP-1)
12867 37 screenmap[id].scriptname = buf;
12868
12869
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 37 times.
37 delete[] buf;
12870 37 }
12871 36 }
12872
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 11)
12873 {
12874 word numspritebindings;
12875 36 p_igetw(&numspritebindings, f);
12876
12877
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 36 times.
46 for(int32_t i=0; i<numspritebindings; i++)
12878 {
12879 word id;
12880 10 p_igetw(&id, f);
12881 10 p_igetl(&bufsize, f);
12882
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
10 if (bufsize < 0 || bufsize > 1024)
12883 return qe_invalid;
12884 10 buf = new char[bufsize+1];
12885 10 pfread(buf, bufsize, f);
12886 10 buf[bufsize]=0;
12887
12888 //fix this too
12889
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(id <NUMSCRIPTSDMAP-1)
12890 10 itemspritemap[id].scriptname = buf;
12891
12892
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 delete[] buf;
12893 10 }
12894 36 }
12895
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version >= 15)
12896 {
12897 word numcombobindings;
12898 36 p_igetw(&numcombobindings, f);
12899
12900
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 36 times.
59 for(int32_t i=0; i<numcombobindings; i++)
12901 {
12902 word id;
12903 23 p_igetw(&id, f);
12904 23 p_igetl(&bufsize, f);
12905
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
23 if (bufsize < 0 || bufsize > 1024)
12906 return qe_invalid;
12907 23 buf = new char[bufsize+1];
12908 23 pfread(buf, bufsize, f);
12909 23 buf[bufsize]=0;
12910
12911 //fix this too
12912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 23 times.
23 if(id <NUMSCRIPTSCOMBODATA-1)
12913 23 comboscriptmap[id].scriptname = buf;
12914
12915
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 delete[] buf;
12916 23 }
12917 36 }
12918
2/2
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 36 times.
113 if(s_version > 19)
12919 {
12920 word numgenericbindings;
12921 36 p_igetw(&numgenericbindings, f);
12922
12923
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 36 times.
49 for(int32_t i=0; i<numgenericbindings; i++)
12924 {
12925 word id;
12926 13 p_igetw(&id, f);
12927 13 p_igetl(&bufsize, f);
12928
2/4
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 13 times.
13 if (bufsize < 0 || bufsize > 1024)
12929 return qe_invalid;
12930 13 buf = new char[bufsize+1];
12931 13 pfread(buf, bufsize, f);
12932 13 buf[bufsize]=0;
12933
12934 //fix this too
12935
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if(id <NUMSCRIPTSGENERIC-1)
12936 13 genericmap[id].scriptname = buf;
12937
12938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 delete[] buf;
12939 13 }
12940 36 }
12941 113 }
12942
12943 113 return 0;
12944 113 }
12945
12946 129 void reset_scripts()
12947 {
12948 #ifdef IS_PLAYER
12949 // We can't modify the script data while jit threads are possibly compiling them.
12950 void jit_shutdown();
12951 129 jit_shutdown();
12952 #endif
12953
12954 129 next_script_data_debug_id = 0;
12955
12956
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12957 {
12958
2/2
✓ Branch 0 taken 42496 times.
✓ Branch 1 taken 23552 times.
66048 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12959
1/2
✓ Branch 0 taken 23552 times.
✗ Branch 1 not taken.
23552 else genericscripts[i] = new script_data();
12960 66048 }
12961
12962
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12963 {
12964
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(ffscripts[i]!=NULL)
12965 {
12966 66048 ffscripts[i]->disable();
12967 66048 }
12968 else
12969 {
12970 ffscripts[i] = new script_data();
12971 }
12972 66048 }
12973
12974
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12975 {
12976
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemscripts[i]!=NULL)
12977 {
12978 33024 itemscripts[i]->disable();
12979 33024 }
12980 else
12981 {
12982 itemscripts[i] = new script_data();
12983 }
12984 33024 }
12985
12986
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12987 {
12988
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(guyscripts[i]!=NULL)
12989 {
12990 33024 guyscripts[i]->disable();
12991 33024 }
12992 else
12993 {
12994 guyscripts[i] = new script_data();
12995 }
12996 33024 }
12997
12998
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12999 {
13000
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(wpnscripts[i]!=NULL)
13001 {
13002 33024 wpnscripts[i]->disable();
13003 33024 }
13004 else
13005 {
13006 wpnscripts[i] = new script_data();
13007 }
13008 33024 }
13009
13010
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
13011 {
13012
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(screenscripts[i]!=NULL)
13013 {
13014 33024 screenscripts[i]->disable();
13015 33024 }
13016 else
13017 {
13018 screenscripts[i] = new script_data();
13019 }
13020 33024 }
13021
13022
2/2
✓ Branch 0 taken 1032 times.
✓ Branch 1 taken 129 times.
1161 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
13023 {
13024
1/2
✓ Branch 0 taken 1032 times.
✗ Branch 1 not taken.
1032 if(globalscripts[i]!=NULL)
13025 {
13026 1032 globalscripts[i]->disable();
13027 1032 }
13028 else
13029 {
13030 globalscripts[i] = new script_data();
13031 }
13032 1032 }
13033
13034
2/2
✓ Branch 0 taken 645 times.
✓ Branch 1 taken 129 times.
774 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
13035 {
13036
1/2
✓ Branch 0 taken 645 times.
✗ Branch 1 not taken.
645 if(playerscripts[i]!=NULL)
13037 {
13038 645 playerscripts[i]->disable();
13039 645 }
13040 else
13041 {
13042 playerscripts[i] = new script_data();
13043 }
13044 645 }
13045
13046
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13047 {
13048
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(lwpnscripts[i]!=NULL)
13049 {
13050 33024 lwpnscripts[i]->disable();
13051 33024 }
13052 else
13053 {
13054 lwpnscripts[i] = new script_data();
13055 }
13056 33024 }
13057
13058
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
13059 {
13060
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(ewpnscripts[i]!=NULL)
13061 {
13062 33024 ewpnscripts[i]->disable();
13063 33024 }
13064 else
13065 {
13066 ewpnscripts[i] = new script_data();
13067 }
13068 33024 }
13069
13070
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
13071 {
13072
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(dmapscripts[i]!=NULL)
13073 {
13074 33024 dmapscripts[i]->disable();
13075 33024 }
13076 else
13077 {
13078 dmapscripts[i] = new script_data();
13079 }
13080 33024 }
13081
13082
2/2
✓ Branch 0 taken 33024 times.
✓ Branch 1 taken 129 times.
33153 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
13083 {
13084
1/2
✓ Branch 0 taken 33024 times.
✗ Branch 1 not taken.
33024 if(itemspritescripts[i]!=NULL)
13085 {
13086 33024 itemspritescripts[i]->disable();
13087 33024 }
13088 else
13089 {
13090 itemspritescripts[i] = new script_data();
13091 }
13092 33024 }
13093
13094
2/2
✓ Branch 0 taken 66048 times.
✓ Branch 1 taken 129 times.
66177 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
13095 {
13096
1/2
✓ Branch 0 taken 66048 times.
✗ Branch 1 not taken.
66048 if(comboscripts[i]!=NULL)
13097 {
13098 66048 comboscripts[i]->disable();
13099 66048 }
13100 else
13101 {
13102 comboscripts[i] = new script_data();
13103 }
13104 66048 }
13105 129 }
13106
13107 extern script_command command_list[];
13108 248303 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
13109 {
13110 //Please also update loadquest() when modifying this method -DD
13111 248303 char b33[34] = {0};
13112 248303 b33[33] = 0;
13113 248303 ffscript temp_script;
13114 248303 int32_t num_commands=1000;
13115
13116
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if(s_version>=2)
13117 {
13118
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if(!p_igetl(&num_commands,f))
13119 {
13120 return qe_invalid;
13121 }
13122 248303 }
13123
13124 #ifdef ZC_FUZZ
13125 const int32_t command_limit = 300000;
13126 #else
13127 248303 const int32_t command_limit = 10000000;
13128 #endif
13129
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 if (num_commands < 0 || num_commands > command_limit)
13130 {
13131 return qe_invalid;
13132 }
13133
13134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 if((*script) != NULL)
13135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248303 times.
248303 delete (*script);
13136
2/4
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 248303 times.
✗ Branch 3 not taken.
248303 (*script) = new script_data(num_commands);
13137
13138
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 118811 times.
248303 if(s_version >= 16)
13139 {
13140
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 zasm_meta temp_meta;
13141
13142
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.zasm_v),f))
13143 {
13144 return qe_invalid;
13145 }
13146
13147
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.meta_v),f))
13148 {
13149 return qe_invalid;
13150 }
13151
13152
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.ffscript_v),f))
13153 {
13154 return qe_invalid;
13155 }
13156
13157
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.script_type),f))
13158 {
13159 return qe_invalid;
13160 }
13161
13162
2/2
✓ Branch 0 taken 1035936 times.
✓ Branch 1 taken 129492 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13163 {
13164
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 978384 times.
1035936 if(zmeta_version < 3)
13165 {
13166
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 1899216 times.
1956768 for(int32_t c = 0; c < 33; ++c)
13167 {
13168
2/4
✓ Branch 0 taken 1899216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1899216 times.
✗ Branch 3 not taken.
1899216 if(!p_getc(&(b33[c]),f))
13169 {
13170 return qe_invalid;
13171 }
13172 1899216 }
13173
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.run_idens[q].assign(b33);
13174 57552 }
13175 else
13176 {
13177
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.run_idens[q],f))
13178 {
13179 return qe_invalid;
13180 }
13181 }
13182 1035936 }
13183
13184
2/2
✓ Branch 0 taken 129492 times.
✓ Branch 1 taken 1035936 times.
1165428 for(int32_t q = 0; q < 8; ++q)
13185 {
13186
2/4
✓ Branch 0 taken 1035936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1035936 times.
✗ Branch 3 not taken.
1035936 if(!p_getc(&(temp_meta.run_types[q]),f))
13187 {
13188 return qe_invalid;
13189 }
13190 1035936 }
13191
13192
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_getc(&(temp_meta.flags),f))
13193 {
13194 return qe_invalid;
13195 }
13196
13197
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v1),f))
13198 {
13199 return qe_invalid;
13200 }
13201
13202
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v2),f))
13203 {
13204 return qe_invalid;
13205 }
13206
13207
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v3),f))
13208 {
13209 return qe_invalid;
13210 }
13211
13212
2/4
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 129492 times.
✗ Branch 3 not taken.
129492 if(!p_igetw(&(temp_meta.compiler_v4),f))
13213 {
13214 return qe_invalid;
13215 }
13216
13217
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 122298 times.
129492 if(zmeta_version == 2)
13218 {
13219
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13220 {
13221
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13222 {
13223 return qe_invalid;
13224 }
13225 237402 }
13226
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.script_name.assign(b33);
13227
13228
2/2
✓ Branch 0 taken 7194 times.
✓ Branch 1 taken 237402 times.
244596 for(int32_t c = 0; c < 33; ++c)
13229 {
13230
2/4
✓ Branch 0 taken 237402 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 237402 times.
✗ Branch 3 not taken.
237402 if(!p_getc(&b33[c],f))
13231 {
13232 return qe_invalid;
13233 }
13234 237402 }
13235
1/2
✓ Branch 0 taken 7194 times.
✗ Branch 1 not taken.
7194 temp_meta.author.assign(b33);
13236 7194 }
13237
1/2
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
122298 else if(zmeta_version > 2)
13238 {
13239
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.script_name,f))
13240 return qe_invalid;
13241
2/4
✓ Branch 0 taken 122298 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122298 times.
✗ Branch 3 not taken.
122298 if(!p_getcstr(&temp_meta.author,f))
13242 return qe_invalid;
13243 122298 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
13244
2/2
✓ Branch 0 taken 1222980 times.
✓ Branch 1 taken 122298 times.
1345278 for(auto q = 0; q < num_meta_attrib; ++q)
13245 {
13246
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getcstr(&temp_meta.attributes[q],f))
13247 return qe_invalid;
13248
2/4
✓ Branch 0 taken 1222980 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1222980 times.
✗ Branch 3 not taken.
1222980 if(!p_getwstr(&temp_meta.attributes_help[q],f))
13249 return qe_invalid;
13250 1222980 }
13251
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13252 {
13253
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attribytes[q],f))
13254 return qe_invalid;
13255
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
13256 return qe_invalid;
13257 978384 }
13258
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13259 {
13260
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.attrishorts[q],f))
13261 return qe_invalid;
13262
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
13263 return qe_invalid;
13264 978384 }
13265
2/2
✓ Branch 0 taken 1956768 times.
✓ Branch 1 taken 122298 times.
2079066 for(auto q = 0; q < 16; ++q)
13266 {
13267
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getcstr(&temp_meta.usrflags[q],f))
13268 return qe_invalid;
13269
2/4
✓ Branch 0 taken 1956768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1956768 times.
✗ Branch 3 not taken.
1956768 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
13270 return qe_invalid;
13271 1956768 }
13272 122298 }
13273
2/2
✓ Branch 0 taken 122298 times.
✓ Branch 1 taken 7194 times.
129492 if(zmeta_version > 3)
13274 {
13275
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13276 {
13277
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getcstr(&temp_meta.initd[q],f))
13278 return qe_invalid;
13279
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getwstr(&temp_meta.initd_help[q],f))
13280 return qe_invalid;
13281 978384 }
13282
2/2
✓ Branch 0 taken 978384 times.
✓ Branch 1 taken 122298 times.
1100682 for(auto q = 0; q < 8; ++q)
13283 {
13284
2/4
✓ Branch 0 taken 978384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 978384 times.
✗ Branch 3 not taken.
978384 if(!p_getc(&temp_meta.initd_type[q],f))
13285 return qe_invalid;
13286 978384 }
13287 122298 }
13288 else
13289 {
13290
2/2
✓ Branch 0 taken 57552 times.
✓ Branch 1 taken 7194 times.
64746 for(auto q = 0; q < 8; ++q)
13291 {
13292
1/2
✓ Branch 0 taken 57552 times.
✗ Branch 1 not taken.
57552 temp_meta.initd[q] = temp_meta.run_idens[q];
13293 57552 }
13294 }
13295
13296
1/2
✓ Branch 0 taken 129492 times.
✗ Branch 1 not taken.
129492 (*script)->meta = temp_meta;
13297
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129492 times.
129492 }
13298
13299
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 temp_script.clear();
13300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21826437 times.
21826437 for(int32_t j=0; j<num_commands; j++)
13301 {
13302
2/4
✓ Branch 0 taken 21826437 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21826437 times.
✗ Branch 3 not taken.
21826437 if(!p_igetw(&(temp_script.command),f))
13303 {
13304 return qe_invalid;
13305 }
13306
13307
2/2
✓ Branch 0 taken 248303 times.
✓ Branch 1 taken 21578134 times.
21826437 if(temp_script.command == 0xFFFF)
13308 {
13309
1/2
✓ Branch 0 taken 248303 times.
✗ Branch 1 not taken.
248303 (*script)->zasm[j].clear();
13310 248303 break;
13311 }
13312 else
13313 {
13314
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg1),f))
13315 {
13316 return qe_invalid;
13317 }
13318
13319
2/4
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21578134 times.
✗ Branch 3 not taken.
21578134 if(!p_igetl(&(temp_script.arg2),f))
13320 {
13321 return qe_invalid;
13322 }
13323
13324
2/2
✓ Branch 0 taken 905513 times.
✓ Branch 1 taken 20672621 times.
21578134 if(s_version >= 21)
13325 {
13326 905513 uint32_t sz = 0;
13327
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13328 {
13329 return qe_invalid;
13330 }
13331
2/2
✓ Branch 0 taken 3202 times.
✓ Branch 1 taken 902311 times.
905513 if(sz) //string found
13332 {
13333
1/2
✓ Branch 0 taken 3202 times.
✗ Branch 1 not taken.
3202 temp_script.strptr = new std::string();
13334 char dummy;
13335
2/2
✓ Branch 0 taken 232733 times.
✓ Branch 1 taken 3202 times.
235935 for(size_t q = 0; q < sz; ++q)
13336 {
13337
2/4
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 232733 times.
✗ Branch 3 not taken.
232733 if(!p_getc(&dummy,f))
13338 {
13339 return qe_invalid;
13340 }
13341
1/2
✓ Branch 0 taken 232733 times.
✗ Branch 1 not taken.
232733 temp_script.strptr->push_back(dummy);
13342 232733 }
13343 3202 }
13344
2/4
✓ Branch 0 taken 905513 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 905513 times.
✗ Branch 3 not taken.
905513 if(!p_igetl(&sz,f))
13345 {
13346 return qe_invalid;
13347 }
13348
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 905412 times.
905513 if(sz) //vector found
13349 {
13350
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 temp_script.vecptr = new std::vector<int32_t>();
13351 int32_t dummy;
13352
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 101 times.
1588 for(size_t q = 0; q < sz; ++q)
13353 {
13354
2/4
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1487 times.
✗ Branch 3 not taken.
1487 if(!p_igetl(&dummy,f))
13355 {
13356 return qe_invalid;
13357 }
13358
1/2
✓ Branch 0 taken 1487 times.
✗ Branch 1 not taken.
1487 temp_script.vecptr->push_back(dummy);
13359 1487 }
13360 101 }
13361 905513 }
13362
13363
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.give((*script)->zasm[j]);
13364 }
13365
1/2
✓ Branch 0 taken 21578134 times.
✗ Branch 1 not taken.
21578134 temp_script.clear();
13366 21578134 }
13367
13368 248303 return 0;
13369 248303 }
13370
13371 extern SAMPLE customsfxdata[WAV_COUNT];
13372 extern uint8_t customsfxflag[WAV_COUNT>>3];
13373 extern int32_t sfxdat;
13374 extern DATAFILE *sfxdata;
13375 const char *old_sfx_string[Z35] =
13376 {
13377 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13378 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13379 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13380 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13381 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13382 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13383 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13384 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13385 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13386 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13387 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13388 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13389 };
13390 char *sfx_string[WAV_COUNT];
13391
13392 113 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13393 {
13394 //these are here to bypass compiler warnings about unused arguments
13395 113 Header=Header;
13396
13397 int32_t dummy;
13398 113 word s_version=0, s_cversion=0;
13399 //int32_t ret;
13400 SAMPLE temp_sample;
13401 113 temp_sample.loop_start=0;
13402 113 temp_sample.loop_end=0;
13403 113 temp_sample.param=0;
13404
13405 //section version info
13406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
13407 {
13408 return qe_invalid;
13409 }
13410
13411 113 FFCore.quest_format[vSFX] = s_version;
13412
13413 //al_trace("SFX version %d\n", s_version);
13414
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
13415 {
13416 return qe_invalid;
13417 }
13418
13419 //section size
13420
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
13421 {
13422 return qe_invalid;
13423 }
13424
13425 /* HIGHLY UNORTHODOX UPDATING THING, by L
13426 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13427 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13428 * changing from 1 to 2.
13429 */
13430
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 2)
13431 set_qr(qr_GOTOLESSNOTEQUAL,1);
13432
13433 /* End highly unorthodox updating thing */
13434
13435 113 int32_t wavcount = WAV_COUNT;
13436
13437
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13438 wavcount = 128;
13439
13440 uint8_t tempflag[WAV_COUNT>>3];
13441
13442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version < 4)
13443 {
13444 memset(tempflag, 0xFF, WAV_COUNT>>3);
13445 }
13446 else
13447 {
13448
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version < 6)
13449 memset(tempflag, 0, WAV_COUNT>>3);
13450
13451
2/2
✓ Branch 0 taken 3616 times.
✓ Branch 1 taken 113 times.
3729 for(int32_t i=0; i<(wavcount>>3); i++)
13452 {
13453 3616 p_getc(&tempflag[i], f);
13454 3616 }
13455
13456 }
13457
13458
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(s_version>4)
13459 {
13460
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<WAV_COUNT; i++)
13461 {
13462 28815 sprintf(sfx_string[i],"s%03d",i);
13463
13464
2/2
✓ Branch 0 taken 22035 times.
✓ Branch 1 taken 6780 times.
28815 if((i<Z35))
13465 6780 strcpy(sfx_string[i], old_sfx_string[i-1]);
13466
13467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28815 times.
28815 if(i>=wavcount)
13468 continue;
13469
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13470 {
13471 char tempname[36];
13472
13473
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!pfread(tempname, 36, f))
13474 {
13475 return qe_invalid;
13476 }
13477
13478 3072 sfx_string[i][0] = '\0';
13479 3072 strncat(sfx_string[i], tempname, 36 - 1);
13480 3072 }
13481 else
13482 {
13483 25743 sprintf(sfx_string[i],"s%03d",i);
13484
13485
2/2
✓ Branch 0 taken 21165 times.
✓ Branch 1 taken 4578 times.
25743 if(i<Z35)
13486 4578 strcpy(sfx_string[i], old_sfx_string[i-1]);
13487 25743 sfx_string[i][35] = 0; //Force NULL Termination
13488 }
13489 28815 }
13490 113 }
13491 else
13492 {
13493 for(int32_t i=1; i<WAV_COUNT; i++)
13494 {
13495 sprintf(sfx_string[i],"s%03d",i);
13496
13497 if(i<Z35)
13498 strcpy(sfx_string[i], old_sfx_string[i-1]);
13499 }
13500 }
13501
13502 //finally... section data
13503
2/2
✓ Branch 0 taken 28815 times.
✓ Branch 1 taken 113 times.
28928 for(int32_t i=1; i<wavcount; i++)
13504 {
13505
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 25743 times.
28815 if(get_bit(tempflag, i-1))
13506 {
13507
13508
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13509 {
13510 return qe_invalid;
13511 }
13512
13513 3072 (temp_sample.bits) = dummy;
13514
13515
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13516 {
13517 return qe_invalid;
13518 }
13519
13520 3072 (temp_sample.stereo) = dummy;
13521
13522
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13523 {
13524 return qe_invalid;
13525 }
13526
13527 3072 (temp_sample.freq) = dummy;
13528
13529
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&dummy,f))
13530 {
13531 return qe_invalid;
13532 }
13533
13534 3072 (temp_sample.priority) = dummy;
13535
13536
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.len),f))
13537 {
13538 return qe_invalid;
13539 }
13540
13541
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_start),f))
13542 {
13543 return qe_invalid;
13544 }
13545
13546
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.loop_end),f))
13547 {
13548 return qe_invalid;
13549 }
13550
13551
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(!p_igetl(&(temp_sample.param),f))
13552 {
13553 return qe_invalid;
13554 }
13555
13556 // al_trace("F%i: L%i\n",i,temp_sample.len);
13557 // temp_sample.data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13558 3072 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13559
2/4
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3072 times.
3072 if (len < 0 || len > 10000000)
13560 {
13561 return qe_invalid;
13562 }
13563 3072 temp_sample.data = calloc(len,1);
13564
13565
1/2
✓ Branch 0 taken 3072 times.
✗ Branch 1 not taken.
3072 if(s_version < 3)
13566 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13567
13568 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13569
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3072 times.
3072 if(s_version < 2)
13570 {
13571 if(!pfread(temp_sample.data, len,f))
13572 {
13573 return qe_invalid;
13574 }
13575 }
13576 else
13577 {
13578 //re-endianfy the data
13579 3072 int32_t wordstoread = len / sizeof(word);
13580
13581
2/2
✓ Branch 0 taken 89161498 times.
✓ Branch 1 taken 3072 times.
89164570 for(int32_t j=0; j<wordstoread; j++)
13582 {
13583 word temp;
13584
13585
1/2
✓ Branch 0 taken 89161498 times.
✗ Branch 1 not taken.
89161498 if(!p_igetw(&temp, f))
13586 {
13587 return qe_invalid;
13588 }
13589
13590 89161498 ((word *)temp_sample.data)[j] = temp;
13591 89161498 }
13592 }
13593 3072 }
13594
2/2
✓ Branch 0 taken 4578 times.
✓ Branch 1 taken 21165 times.
25743 else if(i < Z35)
13595 {
13596 4578 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13597 4578 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13598 4578 set_bit(tempflag, i-1, 1);
13599 4578 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13600 4578 temp_sample.data = calloc(len,1);
13601 4578 memcpy(temp_sample.data, datsamp->data, len);
13602 4578 }
13603 21165 else continue;
13604
13605
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7650 times.
7650 if(customsfxdata[i].data!=NULL)
13606 {
13607 // delete [] customsfxdata[i].data;
13608 7650 free(customsfxdata[i].data);
13609 7650 }
13610
13611 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13612 7650 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13613 7650 customsfxdata[i].data = calloc(len2,1);
13614 7650 customsfxdata[i].bits = temp_sample.bits;
13615 7650 customsfxdata[i].stereo = temp_sample.stereo;
13616 7650 customsfxdata[i].freq = temp_sample.freq;
13617 7650 customsfxdata[i].priority = temp_sample.priority;
13618 7650 customsfxdata[i].len = temp_sample.len;
13619 7650 customsfxdata[i].loop_start = temp_sample.loop_start;
13620 7650 customsfxdata[i].loop_end = temp_sample.loop_end;
13621 7650 customsfxdata[i].param = temp_sample.param;
13622 7650 int32_t cpylen = len2;
13623
13624
1/2
✓ Branch 0 taken 7650 times.
✗ Branch 1 not taken.
7650 if(s_version<3)
13625 {
13626 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13627 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13628 }
13629
13630 7650 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13631
13632 7650 free(temp_sample.data);
13633 7650 }
13634
13635 113 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13636
13637 113 sfxdat=0;
13638 113 return 0;
13639 113 }
13640
13641 129 void setupsfx()
13642 {
13643
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=1; i<WAV_COUNT; i++)
13644 {
13645 32895 sprintf(sfx_string[i],"s%03d",i);
13646
13647
2/2
✓ Branch 0 taken 25155 times.
✓ Branch 1 taken 7740 times.
32895 if(i<Z35)
13648 {
13649 7740 strcpy(sfx_string[i], old_sfx_string[i-1]);
13650 7740 }
13651
13652 32895 memset(customsfxflag, 0, WAV_COUNT>>3);
13653
13654 32895 int32_t j=i;
13655
13656
2/2
✓ Branch 0 taken 7869 times.
✓ Branch 1 taken 25026 times.
32895 if(i>Z35)
13657 {
13658 25026 i=Z35;
13659 25026 }
13660
13661 32895 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13662
13663
2/2
✓ Branch 0 taken 11730 times.
✓ Branch 1 taken 21165 times.
32895 if(customsfxdata[j].data!=NULL)
13664 {
13665 // delete [] customsfxdata[j].data;
13666 21165 free(customsfxdata[j].data);
13667 21165 }
13668
13669 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13670 32895 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13671 32895 customsfxdata[j].bits = temp_sample->bits;
13672 32895 customsfxdata[j].stereo = temp_sample->stereo;
13673 32895 customsfxdata[j].freq = temp_sample->freq;
13674 32895 customsfxdata[j].priority = temp_sample->priority;
13675 32895 customsfxdata[j].len = temp_sample->len;
13676 32895 customsfxdata[j].loop_start = temp_sample->loop_start;
13677 32895 customsfxdata[j].loop_end = temp_sample->loop_end;
13678 32895 customsfxdata[j].param = temp_sample->param;
13679 32895 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13680 32895 i=j;
13681 32895 }
13682 129 }
13683
13684 extern char *guy_string[eMAXGUYS];
13685 extern const char *old_guy_string[OLDMAXGUYS];
13686
13687 129 int32_t readguys(PACKFILE *f, zquestheader *Header)
13688 {
13689 dword dummy;
13690 word guy_cversion;
13691 129 word guyversion=0;
13692
13693
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version >= 0x193)
13694 {
13695 //section version info
13696
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guyversion,f))
13697 {
13698 return qe_invalid;
13699 }
13700
13701 125 FFCore.quest_format[vGuys] = guyversion;
13702
13703 //al_trace("Guys version %d\n", guyversion);
13704
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&guy_cversion,f))
13705 {
13706 return qe_invalid;
13707 }
13708 125 al_trace("Guy CVersion is: %d\n", guy_cversion);
13709 //section size
13710
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
13711 {
13712 return qe_invalid;
13713 }
13714 125 }
13715
13716
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(guyversion > 3)
13717 {
13718
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13719 {
13720 char tempname[64];
13721
13722 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13723 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13724
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13725 {
13726 memset(tempname, 0, sizeof(char)*64);
13727 sprintf(tempname, "e%03d", i);
13728 strcpy(guy_string[i], tempname);
13729
13730 continue;
13731 }
13732
13733
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!pfread(tempname, 64, f))
13734 {
13735 return qe_invalid;
13736 }
13737
13738 // Don't retain names of uneditable enemy entries!
13739 // for version upgrade to 2.5
13740
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
57856 if(guyversion < 23 && i >= 177)
13741 {
13742 // some of the older builds have names such as 'zz123',
13743 // (this order gets messed up with some eXXX and some zzXXX)
13744 // so let's update to the newer naming convection. -Gleeok
13745 char tmpbuf[64];
13746 memset(tmpbuf, 0, sizeof(char)*64);
13747 sprintf(tmpbuf, "zz%03d", i);
13748
13749 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13750 {
13751 memset(tempname, 0, sizeof(char)*64);
13752 sprintf(tempname, "e%03d", i);
13753 }
13754 }
13755
13756
6/6
✓ Branch 0 taken 20001 times.
✓ Branch 1 taken 37855 times.
✓ Branch 2 taken 18984 times.
✓ Branch 3 taken 1017 times.
✓ Branch 4 taken 15955 times.
✓ Branch 5 taken 3029 times.
57856 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13757 {
13758 54827 guy_string[i][0] = '\0';
13759 54827 strncat(guy_string[i], tempname, 64 - 1);
13760 54827 }
13761 else
13762 {
13763 3029 strcpy(guy_string[i],old_guy_string[i]);
13764 }
13765 57856 }
13766 113 }
13767 else
13768 {
13769
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 16 times.
8208 for(int32_t i=0; i<eMAXGUYS; i++)
13770 {
13771 8192 sprintf(guy_string[i],"zz%03d",i);
13772 8192 }
13773
13774
2/2
✓ Branch 0 taken 2832 times.
✓ Branch 1 taken 16 times.
2848 for(int32_t i=0; i<OLDMAXGUYS; i++)
13775 {
13776 2832 strcpy(guy_string[i],old_guy_string[i]);
13777 2832 }
13778 }
13779
13780
13781 //finally... section data
13782 129 init_guys(guyversion); //using default data for now...
13783
13784 // Goriya guy fix
13785
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13786 {
13787
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 12 times.
16 if(get_qr(qr_NEWENEMYTILES))
13788 {
13789 12 guysbuf[gGORIYA].tile=130;
13790 12 guysbuf[gGORIYA].e_tile=130;
13791 12 }
13792 16 }
13793
13794
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version < 0x193)
13795 {
13796
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_bit(deprecated_rules,46))
13797 {
13798 guysbuf[eDODONGO].cset=14;
13799 guysbuf[eDODONGO].bosspal=spDIG;
13800 }
13801 4 }
13802 // Not sure when this first changed, but it's necessary for 2.10, at least
13803 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13804 //2.10 Fixes
13805
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13806 {
13807 16 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13808 16 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13809 16 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13810 16 guysbuf[eCENT1].misc3 = 1;
13811 16 guysbuf[eCENT2].misc3 = 1;
13812 16 }
13813
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13814 {
13815 129 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13816 129 }
13817
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version <= 0x210)
13818 {
13819 16 guysbuf[eGLEEOK1F].misc6 = 16;
13820 16 guysbuf[eGLEEOK2F].misc6 = 16;
13821 16 guysbuf[eGLEEOK3F].misc6 = 16;
13822 16 guysbuf[eGLEEOK4F].misc6 = 16;
13823
13824 16 guysbuf[eWIZ1].misc4 = 1; //only set the enemy that needs backward compat, not all of them.
13825 16 guysbuf[eBATROBE].misc4 = 1;
13826 //guysbuf[eSUMMONER].misc4 = 1;
13827 16 guysbuf[eWWIZ].misc4 = 1;
13828 16 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13829 16 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13830 16 }
13831
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version == 0x190)
13832 {
13833 4 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13834 4 guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13835 4 guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13836 4 }
13837
13838 // The versions here may not be correct
13839 // zelda_version>=0x211 handled at guyversion<24
13840
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version <= 0x190)
13841 {
13842 4 guysbuf[eCENT1].misc3 = 0;
13843 4 guysbuf[eCENT2].misc3 = 0;
13844 4 guysbuf[eMOLDORM].misc2 = 0;
13845 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13846 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13847 4 }
13848
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 else if(Header->zelda_version <= 0x210)
13849 {
13850 12 guysbuf[eCENT1].misc3 = 1;
13851 12 guysbuf[eCENT2].misc3 = 1;
13852 12 guysbuf[eMOLDORM].misc2 = 0;
13853 12 }
13854
13855
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13856 {
13857 16 guysbuf[eKEESE1].misc16 = 120;
13858 16 guysbuf[eKEESE2].misc16 = 120;
13859 16 guysbuf[eKEESE3].misc16 = 120;
13860 16 guysbuf[eKEESETRIB].misc16 = 120;
13861 16 guysbuf[eKEESE1].misc17 = 16;
13862 16 guysbuf[eKEESE2].misc17 = 16;
13863 16 guysbuf[eKEESE3].misc17 = 16;
13864 16 guysbuf[eKEESETRIB].misc17 = 16;
13865
13866 16 guysbuf[ePEAHAT].misc16 = 80;
13867 16 guysbuf[ePEAHAT].misc17 = 16;
13868
13869 16 guysbuf[eGHINI2].misc16 = 120;
13870 16 guysbuf[eGHINI2].misc17 = 10;
13871
13872 16 }
13873
13874
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(guyversion<=2)
13875 {
13876 16 return readherosprites2(f, guyversion==2?0:-1, 0);
13877 }
13878
13879
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(guyversion > 3)
13880 {
13881 guydata tempguy;
13882
13883
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXGUYS; i++)
13884 {
13885
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 23) // May 2012 : 512 max enemies
13886 {
13887 if(i >= OLDBETAMAXGUYS)
13888 {
13889 memset(&guysbuf[i], 0, sizeof(guydata));
13890 continue;
13891 }
13892 }
13893
13894 57856 memset(&tempguy, 0, sizeof(guydata));
13895
13896
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags),f))
13897 {
13898 return qe_invalid;
13899 }
13900
13901
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.flags2),f))
13902 {
13903 return qe_invalid;
13904 }
13905
13906
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13907 {
13908
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tile),f))
13909 {
13910 return qe_invalid;
13911 }
13912 18432 }
13913 else
13914 {
13915
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.tile),f))
13916 {
13917 return qe_invalid;
13918 }
13919 }
13920
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.width),f))
13921 {
13922 return qe_invalid;
13923 }
13924
13925
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.height),f))
13926 {
13927 return qe_invalid;
13928 }
13929
13930
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13931 {
13932
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.s_tile),f))
13933 {
13934 return qe_invalid;
13935 }
13936 18432 }
13937 else
13938 {
13939
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.s_tile),f))
13940 {
13941 return qe_invalid;
13942 }
13943 }
13944
13945
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_width),f))
13946 {
13947 return qe_invalid;
13948 }
13949
13950
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.s_height),f))
13951 {
13952 return qe_invalid;
13953 }
13954
13955
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion >= 36 ) //expanded tiles
13956 {
13957
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.e_tile),f))
13958 {
13959 return qe_invalid;
13960 }
13961 18432 }
13962 else
13963 {
13964
1/2
✓ Branch 0 taken 39424 times.
✗ Branch 1 not taken.
39424 if(!p_igetw(&(tempguy.e_tile),f))
13965 {
13966 return qe_invalid;
13967 }
13968 }
13969
13970
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_width),f))
13971 {
13972 return qe_invalid;
13973 }
13974
13975
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.e_height),f))
13976 {
13977 return qe_invalid;
13978 }
13979
13980
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hp),f))
13981 {
13982 return qe_invalid;
13983 }
13984
13985
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.family),f))
13986 {
13987 return qe_invalid;
13988 }
13989
13990
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
57856 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13991 {
13992 if(get_qr(qr_NEWENEMYTILES))
13993 {
13994 tempguy.s_tile=tempguy.e_tile+120;
13995 tempguy.s_width=tempguy.e_width;
13996 tempguy.s_height=tempguy.e_height;
13997 }
13998 else tempguy.s_tile=860;
13999 }
14000
14001
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.cset),f))
14002 {
14003 return qe_invalid;
14004 }
14005
14006
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.anim),f))
14007 {
14008 return qe_invalid;
14009 }
14010
14011
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_anim),f))
14012 {
14013 return qe_invalid;
14014 }
14015
14016
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.frate),f))
14017 {
14018 return qe_invalid;
14019 }
14020
14021
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.e_frate),f))
14022 {
14023 return qe_invalid;
14024 }
14025
14026
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 13) // April 2009
14027 {
14028 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
14029 {
14030 tempguy.frate *= 2;
14031 tempguy.e_frate *= 2;
14032 }
14033 }
14034
14035
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 14) // May 1 2009
14036 {
14037 if(tempguy.anim==a2FRMSLOW)
14038 {
14039 tempguy.anim=a2FRM;
14040 tempguy.frate *= 2;
14041 }
14042
14043 if(tempguy.e_anim==a2FRMSLOW)
14044 {
14045 tempguy.e_anim=a2FRM;
14046 tempguy.e_frate *= 2;
14047 }
14048
14049 if(tempguy.anim==aFLIPSLOW)
14050 {
14051 tempguy.anim=aFLIP;
14052 tempguy.frate *= 2;
14053 }
14054
14055 if(tempguy.e_anim==aFLIPSLOW)
14056 {
14057 tempguy.e_anim=aFLIP;
14058 tempguy.e_frate *= 2;
14059 }
14060
14061 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
14062
14063 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
14064
14065 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
14066 {
14067 tempguy.anim=a4FRM4DIR;
14068 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14069 }
14070
14071 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
14072 {
14073 tempguy.e_anim=a4FRM4DIR;
14074 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
14075 }
14076 }
14077
14078
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.dp),f))
14079 {
14080 return qe_invalid;
14081 }
14082
14083 //correction for guy fire
14084
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 6)
14085 {
14086 if(i == gFIRE)
14087 tempguy.dp = 2;
14088 }
14089
14090
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.wdp),f))
14091 {
14092 return qe_invalid;
14093 }
14094
14095
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.weapon),f))
14096 {
14097 return qe_invalid;
14098 }
14099
14100 //correction for bosses using triple, "rising" fireballs
14101
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 5)
14102 {
14103 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
14104 i == eGOHMA3 || i == eGOHMA4)
14105 {
14106 if(tempguy.weapon == ewFireball)
14107 tempguy.weapon = ewFireball2;
14108 }
14109 }
14110
14111
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.rate),f))
14112 {
14113 return qe_invalid;
14114 }
14115
14116
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.hrate),f))
14117 {
14118 return qe_invalid;
14119 }
14120
14121
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.step),f))
14122 {
14123 return qe_invalid;
14124 }
14125
14126 // HIGHLY UNORTHODOX UPDATING THING, part 2
14127
3/4
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 56320 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
57856 if(fixpolsvoice && tempguy.family==eePOLSV)
14128 {
14129 tempguy.step /= 2;
14130 }
14131
14132
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.homing),f))
14133 {
14134 return qe_invalid;
14135 }
14136
14137
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.grumble),f))
14138 {
14139 return qe_invalid;
14140 }
14141
14142
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.item_set),f))
14143 {
14144 return qe_invalid;
14145 }
14146
14147
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
14148 {
14149
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc1),f))
14150 {
14151 return qe_invalid;
14152 }
14153
14154
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc2),f))
14155 {
14156 return qe_invalid;
14157 }
14158
14159
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc3),f))
14160 {
14161 return qe_invalid;
14162 }
14163
14164
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc4),f))
14165 {
14166 return qe_invalid;
14167 }
14168
14169
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc5),f))
14170 {
14171 return qe_invalid;
14172 }
14173
14174
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc6),f))
14175 {
14176 return qe_invalid;
14177 }
14178
14179
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc7),f))
14180 {
14181 return qe_invalid;
14182 }
14183
14184
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc8),f))
14185 {
14186 return qe_invalid;
14187 }
14188
14189
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc9),f))
14190 {
14191 return qe_invalid;
14192 }
14193
14194
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc10),f))
14195 {
14196 return qe_invalid;
14197 }
14198 57856 }
14199 else
14200 {
14201 int16_t tempMisc;
14202
14203 if(!p_igetw(&tempMisc,f))
14204 {
14205 return qe_invalid;
14206 }
14207
14208 tempguy.misc1=tempMisc;
14209
14210 if(!p_igetw(&tempMisc,f))
14211 {
14212 return qe_invalid;
14213 }
14214
14215 tempguy.misc2=tempMisc;
14216
14217 if(!p_igetw(&tempMisc,f))
14218 {
14219 return qe_invalid;
14220 }
14221
14222 tempguy.misc3=tempMisc;
14223
14224 if(!p_igetw(&tempMisc,f))
14225 {
14226 return qe_invalid;
14227 }
14228
14229 tempguy.misc4=tempMisc;
14230
14231 if(!p_igetw(&tempMisc,f))
14232 {
14233 return qe_invalid;
14234 }
14235
14236 tempguy.misc5=tempMisc;
14237
14238 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
14239 {
14240 if(tempguy.family == eeWIZZ && !(tempguy.misc1))
14241 tempguy.misc5 = 74;
14242 }
14243
14244 if(!p_igetw(&tempMisc,f))
14245 {
14246 return qe_invalid;
14247 }
14248
14249 tempguy.misc6=tempMisc;
14250
14251 if(!p_igetw(&tempMisc,f))
14252 {
14253 return qe_invalid;
14254 }
14255
14256 tempguy.misc7=tempMisc;
14257
14258 if(!p_igetw(&tempMisc,f))
14259 {
14260 return qe_invalid;
14261 }
14262
14263 tempguy.misc8=tempMisc;
14264
14265 if(!p_igetw(&tempMisc,f))
14266 {
14267 return qe_invalid;
14268 }
14269
14270 tempguy.misc9=tempMisc;
14271
14272 if(!p_igetw(&tempMisc,f))
14273 {
14274 return qe_invalid;
14275 }
14276
14277 tempguy.misc10=tempMisc;
14278 }
14279
14280
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bgsfx),f))
14281 {
14282 return qe_invalid;
14283 }
14284
14285
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.bosspal),f))
14286 {
14287 return qe_invalid;
14288 }
14289
14290
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetw(&(tempguy.extend),f))
14291 {
14292 return qe_invalid;
14293 }
14294
14295 //! Enemy Defences
14296
14297 //If a 2.50 quest, use only the 2.5 defences.
14298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
14299 {
14300
2/2
✓ Branch 0 taken 1099264 times.
✓ Branch 1 taken 57856 times.
1157120 for(int32_t j=0; j<edefLAST; j++)
14301 {
14302
1/2
✓ Branch 0 taken 1099264 times.
✗ Branch 1 not taken.
1099264 if(!p_getc(&(tempguy.defense[j]),f))
14303 {
14304 return qe_invalid;
14305 }
14306 1099264 }
14307 //then copy the generic script defence to all the new script defences
14308
14309 57856 }
14310
14311
14312
14313
14314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57856 times.
57856 if(guyversion >= 18)
14315 {
14316
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.hitsfx),f))
14317 {
14318 return qe_invalid;
14319 }
14320
14321
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_getc(&(tempguy.deadsfx),f))
14322 {
14323 return qe_invalid;
14324 }
14325 57856 }
14326
14327
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion >= 22)
14328 {
14329
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc11),f))
14330 {
14331 return qe_invalid;
14332 }
14333
14334
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(!p_igetl(&(tempguy.misc12),f))
14335 {
14336 return qe_invalid;
14337 }
14338 57856 }
14339 else if(guyversion >= 19)
14340 {
14341 int16_t tempMisc;
14342
14343 if(!p_igetw(&tempMisc,f))
14344 {
14345 return qe_invalid;
14346 }
14347
14348 tempguy.misc11=tempMisc;
14349
14350 if(!p_igetw(&tempMisc,f))
14351 {
14352 return qe_invalid;
14353 }
14354
14355 tempguy.misc12=tempMisc;
14356 }
14357
14358 //If a 2.54 or later quest, use all of the defences.
14359
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 24) // Add new guyversion conditional statement
14360 {
14361
2/2
✓ Branch 0 taken 405504 times.
✓ Branch 1 taken 18432 times.
423936 for(int32_t j=edefLAST; j<edefLAST255; j++)
14362 {
14363
1/2
✓ Branch 0 taken 405504 times.
✗ Branch 1 not taken.
405504 if(!p_getc(&(tempguy.defense[j]),f))
14364 {
14365 return qe_invalid;
14366 }
14367 405504 }
14368 18432 }
14369
14370
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
14371 {
14372
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
14373 {
14374 394240 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
14375 394240 }
14376 39424 }
14377
14378 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
14379
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 25)
14380 {
14381
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.txsz),f))
14382 {
14383 return qe_invalid;
14384 }
14385
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.tysz),f))
14386 {
14387 return qe_invalid;
14388 }
14389
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxsz),f))
14390 {
14391 return qe_invalid;
14392 }
14393
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hysz),f))
14394 {
14395 return qe_invalid;
14396 }
14397
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hzsz),f))
14398 {
14399 return qe_invalid;
14400 }
14401 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14402
14403 */
14404 18432 }
14405 //More Enemy Editor vars for 2.60
14406
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 26)
14407 {
14408
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hxofs),f))
14409 {
14410 return qe_invalid;
14411 }
14412
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.hyofs),f))
14413 {
14414 return qe_invalid;
14415 }
14416
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.xofs),f))
14417 {
14418 return qe_invalid;
14419 }
14420
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.yofs),f))
14421 {
14422 return qe_invalid;
14423 }
14424
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.zofs),f))
14425 {
14426 return qe_invalid;
14427 }
14428 18432 }
14429
14430
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14431 {
14432 39424 tempguy.wpnsprite = 0;
14433 39424 }
14434
14435
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 27)
14436 {
14437
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.wpnsprite),f))
14438 {
14439 return qe_invalid;
14440 }
14441 18432 }
14442
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14443 {
14444 39424 tempguy.SIZEflags = 0;
14445 39424 }
14446
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion > 28)
14447 {
14448
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.SIZEflags),f))
14449 {
14450 return qe_invalid;
14451 }
14452
14453 18432 }
14454
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14455 {
14456 39424 tempguy.frozentile = 0;
14457 39424 tempguy.frozencset = 0;
14458 39424 tempguy.frozenclock = 0;
14459
2/2
✓ Branch 0 taken 394240 times.
✓ Branch 1 taken 39424 times.
433664 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14460 39424 }
14461
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 30)
14462 {
14463
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozentile),f))
14464 {
14465 return qe_invalid;
14466 }
14467
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozencset),f))
14468 {
14469 return qe_invalid;
14470 }
14471
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.frozenclock),f))
14472 {
14473 return qe_invalid;
14474 }
14475
2/2
✓ Branch 0 taken 184320 times.
✓ Branch 1 taken 18432 times.
202752 for ( int32_t q = 0; q < 10; q++ ) {
14476
1/2
✓ Branch 0 taken 184320 times.
✗ Branch 1 not taken.
184320 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14477 {
14478 return qe_invalid;
14479 }
14480 184320 }
14481
14482 18432 }
14483
14484
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 34)
14485 {
14486
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.firesfx),f))
14487 {
14488 return qe_invalid;
14489 }
14490
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc16),f))
14491 {
14492 return qe_invalid;
14493 }
14494
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc17),f))
14495 {
14496 return qe_invalid;
14497 }
14498
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc18),f))
14499 {
14500 return qe_invalid;
14501 }
14502
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc19),f))
14503 {
14504 return qe_invalid;
14505 }
14506
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc20),f))
14507 {
14508 return qe_invalid;
14509 }
14510
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc21),f))
14511 {
14512 return qe_invalid;
14513 }
14514
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc22),f))
14515 {
14516 return qe_invalid;
14517 }
14518
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc23),f))
14519 {
14520 return qe_invalid;
14521 }
14522
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc24),f))
14523 {
14524 return qe_invalid;
14525 }
14526
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc25),f))
14527 {
14528 return qe_invalid;
14529 }
14530
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc26),f))
14531 {
14532 return qe_invalid;
14533 }
14534
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc27),f))
14535 {
14536 return qe_invalid;
14537 }
14538
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc28),f))
14539 {
14540 return qe_invalid;
14541 }
14542
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc29),f))
14543 {
14544 return qe_invalid;
14545 }
14546
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc30),f))
14547 {
14548 return qe_invalid;
14549 }
14550
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc31),f))
14551 {
14552 return qe_invalid;
14553 }
14554
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc32),f))
14555 {
14556 return qe_invalid;
14557 }
14558
14559
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14560
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.movement[q]),f))
14561 {
14562 return qe_invalid;
14563 }
14564 589824 }
14565
2/2
✓ Branch 0 taken 589824 times.
✓ Branch 1 taken 18432 times.
608256 for ( int32_t q = 0; q < 32; q++ ) {
14566
1/2
✓ Branch 0 taken 589824 times.
✗ Branch 1 not taken.
589824 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14567 {
14568 return qe_invalid;
14569 }
14570 589824 }
14571
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.script),f))
14572 {
14573 return qe_invalid;
14574 }
14575 //al_trace("NPC Script ID is: %d\n",tempguy.script);
14576
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14577 {
14578
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.initD[q]),f))
14579 {
14580 return qe_invalid;
14581 }
14582 147456 }
14583
2/2
✓ Branch 0 taken 36864 times.
✓ Branch 1 taken 18432 times.
55296 for ( int32_t q = 0; q < 2; q++ )
14584 {
14585
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(!p_igetl(&(tempguy.initA[q]),f))
14586 {
14587 return qe_invalid;
14588 }
14589 36864 }
14590
14591 18432 }
14592
14593
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 37)
14594 {
14595
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.editorflags),f))
14596 {
14597 return qe_invalid;
14598 }
14599 18432 }
14600
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14601
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if(guyversion >= 38)
14602 {
14603
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc13),f))
14604 {
14605 return qe_invalid;
14606 }
14607
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc14),f))
14608 {
14609 return qe_invalid;
14610 }
14611
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetl(&(tempguy.misc15),f))
14612 {
14613 return qe_invalid;
14614 }
14615
14616 18432 }
14617
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 38 )
14618 {
14619 39424 tempguy.misc13 = 0;
14620 39424 tempguy.misc14 = 0;
14621 39424 tempguy.misc15 = 0;
14622 39424 }
14623
14624
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 39 )
14625 {
14626
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14627 {
14628
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14629 {
14630
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14631 {
14632 return qe_invalid;
14633 }
14634 9584640 }
14635
2/2
✓ Branch 0 taken 9584640 times.
✓ Branch 1 taken 147456 times.
9732096 for ( int32_t w = 0; w < 65; w++ )
14636 {
14637
1/2
✓ Branch 0 taken 9584640 times.
✗ Branch 1 not taken.
9584640 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14638 {
14639 return qe_invalid;
14640 }
14641 9584640 }
14642 147456 }
14643
14644
14645 18432 }
14646
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 39 ) //apply old InitD strings to both
14647 {
14648
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ )
14649 {
14650 315392 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14651 315392 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14652 315392 }
14653 39424 }
14654
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 40 )
14655 {
14656
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_igetw(&(tempguy.weaponscript),f))
14657 {
14658 return qe_invalid;
14659 }
14660 18432 }
14661
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if ( guyversion < 40 )
14662 {
14663 39424 tempguy.weaponscript = 0;
14664 39424 }
14665 //eweapon script InitD
14666
2/2
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
57856 if ( guyversion >= 41 )
14667 {
14668
2/2
✓ Branch 0 taken 147456 times.
✓ Branch 1 taken 18432 times.
165888 for ( int32_t q = 0; q < 8; q++ )
14669 {
14670
1/2
✓ Branch 0 taken 147456 times.
✗ Branch 1 not taken.
147456 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14671 {
14672 return qe_invalid;
14673 }
14674 147456 }
14675
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if ( guy_cversion < 4 )
14676 {
14677 if ( tempguy.family == eeKEESE )
14678 {
14679
14680 if ( !tempguy.misc1 )
14681 {
14682 tempguy.misc16 = 120;
14683 tempguy.misc17 = 16;
14684
14685 }
14686 }
14687 if ( tempguy.family == eePEAHAT )
14688 {
14689 tempguy.misc16 = 80;
14690 tempguy.misc17 = 16;
14691 }
14692
14693 if ( tempguy.family == eeGHINI )
14694 {
14695 tempguy.misc16 = 120;
14696 tempguy.misc17 = 10;
14697 }
14698
14699 }
14700 18432 }
14701
14702
14703
14704 //default weapon sprites (quest version < 2.54)
14705 //port over old defaults -Z
14706
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 32)
14707 {
14708
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.wpnsprite <= 0 )
14709 {
14710
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14711 {
14712 case wNone:
14713 32842 tempguy.wpnsprite = 0; break;
14714
14715 case wSword:
14716 case wBeam:
14717 case wBrang:
14718 case wBomb:
14719 case wSBomb:
14720 case wLitBomb:
14721 case wLitSBomb:
14722 case wArrow:
14723 case wFire:
14724 case wWhistle:
14725 case wBait:
14726 case wWand:
14727 case wMagic:
14728 case wCatching:
14729 case wWind:
14730 case wRefMagic:
14731 case wRefFireball:
14732 case wRefRock:
14733 case wHammer:
14734 case wHookshot:
14735 case wHSHandle:
14736 case wHSChain:
14737 case wSSparkle:
14738 case wFSparkle:
14739 case wSmack:
14740 case wPhantom:
14741 case wCByrna:
14742 case wRefBeam:
14743 case wStomp:
14744 case lwMax:
14745 case wScript1:
14746 case wScript2:
14747 case wScript3:
14748 case wScript4:
14749 case wScript5:
14750 case wScript6:
14751 case wScript7:
14752 case wScript8:
14753 case wScript9:
14754 case wScript10:
14755 case wIce:
14756 //Cannot use any of these weapons yet.
14757 tempguy.wpnsprite = -1;
14758 break;
14759
14760 case wEnemyWeapons:
14761 1303 case ewFireball: tempguy.wpnsprite = 17; break;
14762
14763 302 case ewArrow: tempguy.wpnsprite = 19; break;
14764 314 case ewBrang: tempguy.wpnsprite = 4; break;
14765 931 case ewSword: tempguy.wpnsprite = 20; break;
14766 493 case ewRock: tempguy.wpnsprite = 18; break;
14767 912 case ewMagic: tempguy.wpnsprite = 21; break;
14768 80 case ewBomb: tempguy.wpnsprite = 78; break;
14769 18 case ewSBomb: tempguy.wpnsprite = 79; break;
14770 137 case ewLitBomb: tempguy.wpnsprite = 76; break;
14771 19 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14772 363 case ewFireTrail: tempguy.wpnsprite = 80; break;
14773 759 case ewFlame: tempguy.wpnsprite = 35; break;
14774 106 case ewWind: tempguy.wpnsprite = 36; break;
14775 80 case ewFlame2: tempguy.wpnsprite = 81; break;
14776 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14777 case ewIce: tempguy.wpnsprite = 83; break;
14778 765 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14779
14780
14781 default: break; //No assign.
14782 }
14783 39424 }
14784 39424 }
14785
14786 //default weapon fire sound (quest version < 2.54)
14787 //port over old defaults and zero new data. -Z
14788
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 34)
14789 {
14790
2/2
✓ Branch 0 taken 1261568 times.
✓ Branch 1 taken 39424 times.
1300992 for ( int32_t q = 0; q < 32; q++ )
14791 {
14792 1261568 tempguy.movement[q] = 0;
14793 1261568 tempguy.new_weapon[q] = 0;
14794
14795 1261568 }
14796
14797 //NPC Script attributes.
14798 39424 tempguy.script = 0; //No scripted enemies existed. -Z
14799
2/2
✓ Branch 0 taken 315392 times.
✓ Branch 1 taken 39424 times.
354816 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14800
2/2
✓ Branch 0 taken 78848 times.
✓ Branch 1 taken 39424 times.
118272 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14801
14802 39424 tempguy.misc16 = 0;
14803 39424 tempguy.misc17 = 0;
14804 39424 tempguy.misc18 = 0;
14805 39424 tempguy.misc19 = 0;
14806 39424 tempguy.misc20 = 0;
14807 39424 tempguy.misc21 = 0;
14808 39424 tempguy.misc22 = 0;
14809 39424 tempguy.misc23 = 0;
14810 39424 tempguy.misc24 = 0;
14811 39424 tempguy.misc25 = 0;
14812 39424 tempguy.misc26 = 0;
14813 39424 tempguy.misc27 = 0;
14814 39424 tempguy.misc28 = 0;
14815 39424 tempguy.misc29 = 0;
14816 39424 tempguy.misc30 = 0;
14817 39424 tempguy.misc31 = 0;
14818 39424 tempguy.misc32 = 0;
14819
14820 //old default sounds
14821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 39424 times.
39424 if ( tempguy.firesfx <= 0 )
14822 {
14823
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 1303 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32842 times.
✓ Branch 4 taken 302 times.
✓ Branch 5 taken 314 times.
✓ Branch 6 taken 931 times.
✓ Branch 7 taken 493 times.
✓ Branch 8 taken 912 times.
✓ Branch 9 taken 80 times.
✓ Branch 10 taken 18 times.
✓ Branch 11 taken 137 times.
✓ Branch 12 taken 19 times.
✓ Branch 13 taken 363 times.
✓ Branch 14 taken 759 times.
✓ Branch 15 taken 106 times.
✓ Branch 16 taken 80 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 765 times.
39424 switch(tempguy.weapon)
14824 {
14825 case wNone:
14826 32842 tempguy.firesfx = 0; break;
14827
14828 case wSword:
14829 case wBeam:
14830 case wBrang:
14831 case wBomb:
14832 case wSBomb:
14833 case wLitBomb:
14834 case wLitSBomb:
14835 case wArrow:
14836 case wFire:
14837 case wWhistle:
14838 case wBait:
14839 case wWand:
14840 case wMagic:
14841 case wCatching:
14842 case wWind:
14843 case wRefMagic:
14844 case wRefFireball:
14845 case wRefRock:
14846 case wHammer:
14847 case wHookshot:
14848 case wHSHandle:
14849 case wHSChain:
14850 case wSSparkle:
14851 case wFSparkle:
14852 case wSmack:
14853 case wPhantom:
14854 case wCByrna:
14855 case wRefBeam:
14856 case wStomp:
14857 case lwMax:
14858 case wScript1:
14859 case wScript2:
14860 case wScript3:
14861 case wScript4:
14862 case wScript5:
14863 case wScript6:
14864 case wScript7:
14865 case wScript8:
14866 case wScript9:
14867 case wScript10:
14868 case wIce:
14869 //Cannot use any of these weapons yet.
14870 tempguy.firesfx = -1;
14871 break;
14872
14873 case wEnemyWeapons:
14874 1303 case ewFireball: tempguy.firesfx = 40; break;
14875
14876 302 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14877 314 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14878 931 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14879 493 case ewRock: tempguy.firesfx = 51; break;
14880 912 case ewMagic: tempguy.firesfx = 32; break;
14881 80 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14882 18 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14883 137 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14884 19 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14885 363 case ewFireTrail: tempguy.firesfx = 13; break;
14886 759 case ewFlame: tempguy.firesfx = 13; break;
14887 106 case ewWind: tempguy.firesfx = 32; break;
14888 80 case ewFlame2: tempguy.firesfx = 13; break;
14889 case ewFlame2Trail: tempguy.firesfx = 13; break;
14890 case ewIce: tempguy.firesfx = 44; break;
14891 765 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14892
14893 //what about special attacks (e.g. summoning == 56)
14894 default: break; //No assign.
14895 }
14896 39424 }
14897 39424 }
14898
14899 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14900
4/6
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
✓ Branch 2 taken 18432 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18432 times.
57856 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14901 {
14902
2/2
✓ Branch 0 taken 3549 times.
✓ Branch 1 taken 35875 times.
39424 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14903 39424 }
14904 //Keese and bat halt rates.
14905
3/4
✓ Branch 0 taken 39424 times.
✓ Branch 1 taken 18432 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 39424 times.
57856 if ( guyversion < 42 && guy_cversion < 4 )
14906 {
14907
14908
2/2
✓ Branch 0 taken 38895 times.
✓ Branch 1 taken 529 times.
39424 if ( tempguy.family == eeKEESE )
14909 {
14910
14911
2/2
✓ Branch 0 taken 203 times.
✓ Branch 1 taken 326 times.
529 if ( !tempguy.misc1 )
14912 {
14913 326 tempguy.misc16 = 120;
14914 326 tempguy.misc17 = 16;
14915
14916 326 }
14917 529 }
14918
2/2
✓ Branch 0 taken 39257 times.
✓ Branch 1 taken 167 times.
39424 if ( tempguy.family == eePEAHAT )
14919 {
14920 167 tempguy.misc16 = 80;
14921 167 tempguy.misc17 = 16;
14922 167 }
14923
2/2
✓ Branch 0 taken 39347 times.
✓ Branch 1 taken 77 times.
39424 if ( tempguy.family == eeGHINI )
14924 {
14925 77 tempguy.misc16 = 120;
14926 77 tempguy.misc17 = 10;
14927 77 }
14928
14929
14930 39424 }
14931
14932
14933 //miscellaneous other corrections
14934 //fix the mirror wizzrobe -DD
14935
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 7)
14936 {
14937 if(i == eMWIZ)
14938 {
14939 tempguy.misc2 = 0;
14940 tempguy.misc4 = 1;
14941 }
14942 }
14943
14944
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 8)
14945 {
14946 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14947 {
14948 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14949 tempguy.misc5 = 4; //neck length in segments
14950 tempguy.misc6 = 8; //neck offset from first body tile
14951 tempguy.misc7 = 40; //offset for each subsequent neck tile from the first neck tile
14952 tempguy.misc8 = 168; //head offset from first body tile
14953 tempguy.misc9 = 228; //flying head offset from first body tile
14954
14955 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14956 {
14957 tempguy.misc6 += 10; //neck offset from first body tile
14958 tempguy.misc8 -= 12; //head offset from first body tile
14959 }
14960 }
14961 }
14962
14963
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14964 {
14965 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.misc1==0)
14966 tempguy.bosspal = spDIG;
14967 }
14968
14969
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 11) // December 2007 - Spinning Tile fix
14970 {
14971 if(tempguy.family==eeSPINTILE)
14972 {
14973 tempguy.flags |= guy_superman;
14974 tempguy.item_set = 0; // Don't drop items
14975 tempguy.step = 300;
14976 }
14977 }
14978
14979
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14980 {
14981 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14982 {
14983 if(tempguy.family==eeROPE)
14984 {
14985 tempguy.flags2 &= ~guy_flashing;
14986 }
14987 }
14988
14989 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14990 {
14991 if(tempguy.family==eeBUBBLE)
14992 {
14993 tempguy.flags2 &= ~guy_flashing;
14994 }
14995 }
14996
14997 if((tempguy.family==eeGHINI)&&(tempguy.misc1))
14998 {
14999 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
15000 {
15001 tempguy.flags2 |= guy_blinking;
15002 }
15003
15004 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
15005 {
15006 tempguy.flags2 |= guy_transparent;
15007 }
15008 }
15009 }
15010
15011
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
15012 {
15013 if(i==gFIRE)
15014 {
15015 tempguy.e_anim = aFLIP;
15016 tempguy.e_frate = 24;
15017 }
15018
15019 if(i==gFAIRY)
15020 {
15021 tempguy.e_anim = a2FRM;
15022 tempguy.e_frate = 16;
15023 }
15024 }
15025
15026
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
15027 {
15028 if(i==0) Z_message("Updating guys to version 16...\n");
15029
15030 update_guy_1(&tempguy);
15031
15032 if(i==eMPOLSV)
15033 {
15034 tempguy.defense[edefARROW] = edCHINK;
15035 tempguy.defense[edefMAGIC] = ed1HKO;
15036 tempguy.defense[edefREFMAGIC] = ed1HKO;
15037 }
15038 }
15039
15040
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 17) // December 2009
15041 {
15042 if(tempguy.family==eePROJECTILE)
15043 {
15044 tempguy.misc1 = 0;
15045 }
15046 }
15047
15048
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 18) // January 2010
15049 {
15050 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
15051 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
15052
15053 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
15054 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.misc10 == 0)) ? WAV_GASP : WAV_EDEAD;
15055
15056 if(tempguy.family == eeAQUA)
15057 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
15058 else if(tempguy.family == eeMANHAN)
15059 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
15060 else if(tempguy.family==eePATRA)
15061 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15062 else if(tempguy.family==eeGHOMA)
15063 {
15064 for(int32_t j=0; j<edefLAST; j++)
15065 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
15066
15067 tempguy.defense[edefARROW] = ((tempguy.misc1==3) ? edCHINKL8 : (tempguy.misc1==2) ? edCHINKL4 : 0);
15068
15069 if(tempguy.misc1==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
15070
15071 tempguy.misc1--;
15072 }
15073 else if(tempguy.family == eeGLEEOK)
15074 {
15075 for(int32_t j=0; j<edefLAST; j++)
15076 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
15077
15078 if(tempguy.misc3==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
15079 }
15080 else if(tempguy.family == eeARMOS)
15081 {
15082 tempguy.family=eeWALK;
15083 tempguy.hrate = 0;
15084 tempguy.misc10 = tempguy.misc1;
15085 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 = tempguy.misc7 = tempguy.misc8 = 0;
15086 tempguy.misc9 = e9tARMOS;
15087 }
15088 else if(tempguy.family == eeGHINI && !tempguy.misc1)
15089 {
15090 tempguy.family=eeWALK;
15091 tempguy.hrate = 0;
15092 tempguy.misc1 = tempguy.misc2 = tempguy.misc3 = tempguy.misc4 = tempguy.misc5 = tempguy.misc6 =
15093 tempguy.misc7 = tempguy.misc8 = tempguy.misc9 = tempguy.misc10 = 0;
15094 }
15095
15096 // Spawn animation flags
15097 if(tempguy.family == eeWALK && (tempguy.flags2&cmbflag_armos || tempguy.flags2&cmbflag_ghini))
15098 tempguy.flags |= guy_fadeflicker;
15099 else
15100 tempguy.flags &= 0x0F00000F; // Get rid of the unused flags!
15101 }
15102
15103
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 20) // April 2010
15104 {
15105 if(tempguy.family == eeTRAP)
15106 {
15107 tempguy.misc2 = tempguy.misc10;
15108
15109 if(tempguy.misc10>=1)
15110 {
15111 tempguy.misc1++;
15112 }
15113
15114 tempguy.misc10 = 0;
15115 }
15116
15117 // Bomb Blast fix
15118 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15119 tempguy.weapon = ewLitBomb;
15120 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.misc2 != e2tBOMBCHU))
15121 tempguy.weapon = ewLitSBomb;
15122 }
15123
15124
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 21) // September 2011
15125 {
15126 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
15127 {
15128 if(tempguy.family == eeKEESETRIB)
15129 {
15130 tempguy.family = eeKEESE;
15131 tempguy.misc2 = e2tKEESETRIB;
15132 tempguy.misc1 = 0;
15133 }
15134
15135 tempguy.rate = 2;
15136 tempguy.hrate = 8;
15137 tempguy.homing = 0;
15138 tempguy.step= (tempguy.family == eeKEESE && tempguy.misc1 ? 100:62);
15139 }
15140 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
15141 {
15142 if(tempguy.family == eePEAHAT)
15143 {
15144 tempguy.rate = 4;
15145 tempguy.step = 62;
15146 }
15147 else
15148 tempguy.step = 25;
15149
15150 tempguy.hrate = 8;
15151 tempguy.homing = 0;
15152 }
15153 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
15154 {
15155 if(tempguy.family == eeMANHAN)
15156 tempguy.step=50;
15157
15158 tempguy.hrate = 16;
15159 tempguy.homing = 0;
15160 }
15161 else if(tempguy.family == eeGLEEOK)
15162 {
15163 tempguy.rate = 2;
15164 tempguy.homing = 0;
15165 tempguy.hrate = 9;
15166 tempguy.step=89;
15167 }
15168 else if(tempguy.family == eeGHINI)
15169 {
15170 tempguy.rate = 4;
15171 tempguy.hrate = 12;
15172 tempguy.step=62;
15173 tempguy.homing = 0;
15174 }
15175
15176 // Bigdig random rate fix
15177 if(tempguy.family==eeDIG && tempguy.misc10==1)
15178 {
15179 tempguy.rate = 2;
15180 }
15181 }
15182
15183
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if(guyversion < 24) // November 2012
15184 {
15185 if(tempguy.family==eeLANM)
15186 tempguy.misc3 = 1;
15187 else if(tempguy.family==eeMOLD)
15188 tempguy.misc2 = 0;
15189 }
15190
15191
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
15192 {
15193
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 38764 times.
39424 if(tempguy.family!=eeDIG)
15194 {
15195 38764 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
15196 38764 }
15197
15198 39424 }
15199 // does not seem to solve the issue!
15200
1/2
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
57856 if ( Header->zelda_version <= 0x210 )
15201 {
15202 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
15203 if ( tempguy.family == eeDONGO )
15204 {
15205 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
15206 }
15207 }
15208
15209
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion >= 42)
15210 {
15211
2/2
✓ Branch 0 taken 17408 times.
✓ Branch 1 taken 1024 times.
18432 if(guyversion >= 47)
15212 {
15213
1/2
✓ Branch 0 taken 17408 times.
✗ Branch 1 not taken.
17408 if(!p_igetl(&(tempguy.moveflags),f))
15214 {
15215 return qe_invalid;
15216 }
15217 17408 }
15218 else
15219 {
15220 byte fl;
15221
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(!p_getc(&fl,f))
15222 {
15223 return qe_invalid;
15224 }
15225 1024 tempguy.moveflags = fl;
15226 }
15227 18432 }
15228 else
15229 {
15230
7/8
✓ Branch 0 taken 446 times.
✓ Branch 1 taken 30899 times.
✓ Branch 2 taken 1202 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 518 times.
✓ Branch 5 taken 278 times.
✓ Branch 6 taken 241 times.
✓ Branch 7 taken 5840 times.
39424 switch(tempguy.family)
15231 {
15232 //No gravity; floats over pits
15233 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15234 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15235 //Special (bosses, etc)
15236 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15237 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15238 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15239 30899 tempguy.moveflags = FLAG_CAN_PITWALK;
15240 30899 break;
15241 //No gravity, but falls in pits
15242 case eeLEV:
15243 518 tempguy.moveflags = FLAG_CAN_PITFALL;
15244 518 break;
15245 //Bosses that respect pits
15246 case eeDONGO:
15247 278 tempguy.moveflags = FLAG_OBEYS_GRAV;
15248 278 break;
15249 case eeLANM:
15250 241 tempguy.moveflags = 0;
15251 241 break;
15252 //Gravity, floats over pits
15253 case eeWIZZ: case eeWALLM: case eeGHINI:
15254 1202 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITWALK;
15255 1202 break;
15256 //Gravity and falls in pits
15257 case eeWALK:
15258
4/4
✓ Branch 0 taken 5519 times.
✓ Branch 1 taken 321 times.
✓ Branch 2 taken 280 times.
✓ Branch 3 taken 5239 times.
5840 if (tempguy.misc9==e9tPOLSVOICE||tempguy.misc9==e9tVIRE)
15259 601 break;
15260 [[fallthrough]];
15261 case eeOTHER:
15262 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
15263 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
15264 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
15265 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
15266 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
15267 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
15268 5685 tempguy.moveflags = FLAG_OBEYS_GRAV | FLAG_CAN_PITFALL;
15269 5685 }
15270 }
15271
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 43)
15272 {
15273
2/2
✓ Branch 0 taken 32101 times.
✓ Branch 1 taken 7323 times.
39424 switch(tempguy.family)
15274 {
15275 //No gravity; floats over pits
15276 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
15277 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
15278 //Special (bosses, etc)
15279 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
15280 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
15281 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
15282 case eeWIZZ: case eeWALLM: case eeGHINI:
15283 //Gravity, floats over pits
15284 32101 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15285 32101 break;
15286 }
15287 39424 }
15288
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion < 44)
15289 {
15290
2/2
✓ Branch 0 taken 39054 times.
✓ Branch 1 taken 370 times.
39424 if ( tempguy.family == eeGHOMA )
15291 {
15292 370 tempguy.flags |= guy_fadeinstant;
15293 370 }
15294 39424 }
15295
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if (guyversion > 44)
15296 {
15297
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_shadow),f))
15298 {
15299 return qe_invalid;
15300 }
15301
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_death),f))
15302 {
15303 return qe_invalid;
15304 }
15305
1/2
✓ Branch 0 taken 18432 times.
✗ Branch 1 not taken.
18432 if(!p_getc(&(tempguy.spr_spawn),f))
15306 {
15307 return qe_invalid;
15308 }
15309 18432 }
15310 else
15311 {
15312
2/2
✓ Branch 0 taken 39271 times.
✓ Branch 1 taken 153 times.
39424 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.misc10==1) ? iwLargeShadow : iwShadow;
15313 39424 tempguy.spr_death = iwDeath;
15314 39424 tempguy.spr_spawn = iwSpawn;
15315 }
15316
15317
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 39424 times.
57856 if(guyversion < 46)
15318 {
15319
4/4
✓ Branch 0 taken 5840 times.
✓ Branch 1 taken 33584 times.
✓ Branch 2 taken 5519 times.
✓ Branch 3 taken 321 times.
39424 if(tempguy.family == eeWALK && tempguy.misc9 == e9tPOLSVOICE)
15320 {
15321 321 tempguy.moveflags |= FLAG_CAN_WATERWALK;
15322 321 }
15323 39424 }
15324
15325 57856 guysbuf[i] = tempguy;
15326 57856 }
15327 113 }
15328
15329 113 return 0;
15330 129 }
15331
15332 void update_guy_1(guydata *tempguy) // November 2009
15333 {
15334 bool doesntcount = false;
15335 tempguy->flags &= ~weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
15336
15337 switch(tempguy->family)
15338 {
15339 case 1: //eeWALK
15340 switch(tempguy->misc10)
15341 {
15342 case 0: //Stalfos
15343 if(tempguy->misc1==1) // Fires four projectiles at once
15344 tempguy->misc1=4;
15345
15346 break;
15347
15348 case 1: //Darknut
15349 goto darknuts;
15350 break;
15351 }
15352
15353 tempguy->misc10 = 0;
15354 break;
15355
15356 case 2: //eeSHOOT
15357 tempguy->family = eeWALK;
15358
15359 switch(tempguy->misc10)
15360 {
15361 case 0: //Octorok
15362 if(tempguy->misc1==1||tempguy->misc1==2)
15363 {
15364 tempguy->misc1=e1tFIREOCTO;
15365 tempguy->misc2=e2tFIREOCTO;
15366 }
15367 else tempguy->misc1 = 0;
15368
15369 tempguy->misc6=tempguy->misc4;
15370 tempguy->misc4=tempguy->misc3;
15371 tempguy->misc3=0;
15372 break;
15373
15374 case 1: // Moblin
15375 tempguy->misc1 = 0;
15376 break;
15377
15378 case 2: //Lynel
15379 tempguy->misc6=tempguy->misc1+1;
15380 tempguy->misc1=0;
15381 break;
15382
15383 case 3: //Stalfos 2
15384 if(tempguy->misc1==1) // Fires four projectiles at once
15385 tempguy->misc1=e1t4SHOTS;
15386 else tempguy->misc1 = 0;
15387
15388 break;
15389
15390 case 4: //Darknut 5
15391 darknuts:
15392 tempguy->defense[edefFIRE] = edIGNORE;
15393 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15394 tempguy->defense[edefHOOKSHOT] = 0;
15395 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
15396 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
15397
15398 if(tempguy->misc1==1)
15399 tempguy->misc1=2;
15400 else if(tempguy->misc1==2)
15401 {
15402 tempguy->misc4=tempguy->misc3;
15403 tempguy->misc3=tempguy->misc2;
15404 tempguy->misc2=e2tSPLIT;
15405 tempguy->misc1 = 0;
15406 }
15407 else tempguy->misc1 = 0;
15408
15409 tempguy->flags |= inv_front;
15410
15411 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
15412 tempguy->flags |= guy_bkshield;
15413
15414 break;
15415 }
15416
15417 tempguy->misc10 = 0;
15418 break;
15419
15420 /*
15421 case 9: //eeARMOS
15422 tempguy->family = eeWALK;
15423 break;
15424 */
15425 case 11: //eeGEL
15426 case 33: //eeGELTRIB
15427 if(tempguy->family==33)
15428 {
15429 tempguy->misc4 = 1;
15430
15431 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
15432 tempguy->misc3 = tempguy->misc2;
15433
15434 tempguy->misc2 = e2tTRIBBLE;
15435 }
15436 else
15437 {
15438 tempguy->misc4 = 0;
15439 tempguy->misc3 = 0;
15440 tempguy->misc2 = 0;
15441 }
15442
15443 tempguy->family = eeWALK;
15444
15445 if(tempguy->misc1)
15446 {
15447 tempguy->misc1=1;
15448 tempguy->weapon = ewFireTrail;
15449 }
15450
15451 break;
15452
15453 case 34: //eeZOLTRIB
15454 case 12: //eeZOL
15455 tempguy->misc4=tempguy->misc3;
15456 tempguy->misc3=tempguy->misc2;
15457 tempguy->family = eeWALK;
15458 tempguy->misc2=e2tSPLITHIT;
15459
15460 if(tempguy->misc1)
15461 {
15462 tempguy->misc1=1;
15463 tempguy->weapon = ewFireTrail;
15464 }
15465
15466 break;
15467
15468 case 13: //eeROPE
15469 tempguy->family = eeWALK;
15470 tempguy->misc9 = e9tROPE;
15471
15472 if(tempguy->misc1)
15473 {
15474 tempguy->misc4 = tempguy->misc3;
15475 tempguy->misc3 = tempguy->misc2;
15476 tempguy->misc2 = e2tBOMBCHU;
15477 }
15478
15479 tempguy->misc1 = 0;
15480 break;
15481
15482 case 14: //eeGORIYA
15483 tempguy->family = eeWALK;
15484
15485 if(tempguy->misc1!=2) tempguy->misc1 = 0;
15486
15487 break;
15488
15489 case 17: //eeBUBBLE
15490 tempguy->family = eeWALK;
15491 tempguy->misc8 = tempguy->misc2;
15492 tempguy->misc7 = tempguy->misc1 + 1;
15493 tempguy->misc1 = tempguy->misc2 = 0;
15494
15495 //fallthrogh
15496 case eeTRAP:
15497 case eeROCK:
15498 doesntcount = true;
15499 break;
15500
15501 case 35: //eeVIRETRIB
15502 case 18: //eeVIRE
15503 tempguy->family = eeWALK;
15504 tempguy->misc4=tempguy->misc3;
15505 tempguy->misc3=tempguy->misc2;
15506 tempguy->misc2=e2tSPLITHIT;
15507 tempguy->misc9=e9tVIRE;
15508 break;
15509
15510 case 19: //eeLIKE
15511 tempguy->family = eeWALK;
15512 tempguy->misc7 = e7tEATITEMS;
15513 tempguy->misc8=95;
15514 break;
15515
15516 case 20: //eePOLSV
15517 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15518 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15519 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15520 tempguy->defense[edefARROW] = ed1HKO;
15521 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15522 tempguy->family = eeWALK;
15523 tempguy->misc9 = e9tPOLSVOICE;
15524 tempguy->rate = 4;
15525 tempguy->homing = 32;
15526 tempguy->hrate = 10;
15527 tempguy->grumble = 0;
15528 break;
15529
15530 case eeWIZZ:
15531 if(tempguy->misc4)
15532 {
15533 for(int32_t i=0; i < edefLAST; i++)
15534 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15535 }
15536 else
15537 {
15538 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15539 tempguy->defense[edefMAGIC] = edCHINK;
15540 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15541 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15542 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15543 }
15544
15545 break;
15546
15547 case eePEAHAT:
15548 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15549
15550 if(!(tempguy->flags & guy_bhit))
15551 tempguy->defense[edefBRANG] = edSTUNONLY;
15552
15553 break;
15554
15555 case eeLEV:
15556 tempguy->defense[edefSTOMP] = edCHINK;
15557 break;
15558 }
15559
15560 // Old flags
15561 if(tempguy->flags & guy_superman)
15562 {
15563 for(int32_t i = 0; i < edefLAST; i++)
15564 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15565 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15566 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15567 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15568 }
15569
15570 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15571
15572 if(doesntcount)
15573 tempguy->flags |= (guy_doesntcount);
15574 }
15575
15576
15577 247176 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version)
15578 {
15579 byte tempbyte, padding;
15580 int32_t extras, secretcombos;
15581 //al_trace("readmapscreen Header->zelda_version: %x\n",Header->zelda_version);
15582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->valid),f))
15583 {
15584 return qe_invalid;
15585 }
15586
15587
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->guy),f))
15588 return qe_invalid;
15589 247176 temp_mapscr->guytile = -1; //signal to use default guy values
15590
2/2
✓ Branch 0 taken 246700 times.
✓ Branch 1 taken 476 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15591
4/4
✓ Branch 0 taken 476 times.
✓ Branch 1 taken 246700 times.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 453 times.
247176 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15592
15593
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15594 {
15595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15596 {
15597 return qe_invalid;
15598 }
15599
15600 6864 temp_mapscr->str=tempbyte;
15601 6864 }
15602 else
15603 {
15604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->str),f))
15605 {
15606 return qe_invalid;
15607 }
15608 }
15609
15610
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->room),f))
15611 {
15612 return qe_invalid;
15613 }
15614
15615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->item),f))
15616 {
15617 return qe_invalid;
15618 }
15619
15620
3/6
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 153408 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15621 {
15622 93768 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15623 93768 }
15624 else
15625 {
15626
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->hasitem),f))
15627 return qe_invalid;
15628 }
15629
15630
2/4
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version < 0x192)||
15631
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15632 {
15633
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15634 {
15635 return qe_invalid;
15636 }
15637 6864 }
15638
15639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15640 {
15641 return qe_invalid;
15642 }
15643
15644
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15645 {
15646
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
6864 if(!p_getc(&tempbyte,f))
15647 {
15648 return qe_invalid;
15649 }
15650 6864 }
15651
15652
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15653 {
15654
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15655 {
15656
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15657 {
15658 return qe_invalid;
15659 }
15660 460224 }
15661 153408 }
15662 else
15663 {
15664 93768 temp_mapscr->tilewarptype[1]=0;
15665 93768 temp_mapscr->tilewarptype[2]=0;
15666 93768 temp_mapscr->tilewarptype[3]=0;
15667 }
15668
15669
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15670 {
15671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15672 {
15673 return qe_invalid;
15674 }
15675 240312 }
15676
15677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15678 {
15679 return qe_invalid;
15680 }
15681
15682 247176 temp_mapscr->warpreturnx[1]=0;
15683 247176 temp_mapscr->warpreturnx[2]=0;
15684 247176 temp_mapscr->warpreturnx[3]=0;
15685
15686
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15687 {
15688
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15689 {
15690
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15691 {
15692 return qe_invalid;
15693 }
15694 460224 }
15695 153408 }
15696
15697
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15698 {
15699 return qe_invalid;
15700 }
15701
15702 247176 temp_mapscr->warpreturny[1]=0;
15703 247176 temp_mapscr->warpreturny[2]=0;
15704 247176 temp_mapscr->warpreturny[3]=0;
15705
15706
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15707 {
15708
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15709 {
15710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15711 {
15712 return qe_invalid;
15713 }
15714 460224 }
15715
15716
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(version>=18)
15717 {
15718
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15719 {
15720 return qe_invalid;
15721 }
15722 153408 }
15723 else
15724 {
15725 byte temp;
15726
15727 if(!p_getc(&temp,f))
15728 {
15729 return qe_invalid;
15730 }
15731
15732 temp_mapscr->warpreturnc=temp<<8|temp;
15733 }
15734 153408 }
15735
15736
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->stairx),f))
15737
15738 {
15739 return qe_invalid;
15740 }
15741
15742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->stairy),f))
15743 {
15744 return qe_invalid;
15745 }
15746
15747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemx),f))
15748 {
15749 return qe_invalid;
15750 }
15751
15752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->itemy),f))
15753 {
15754 return qe_invalid;
15755 }
15756
15757
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version > 15) // February 2009
15758 {
15759
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->color),f))
15760 {
15761 return qe_invalid;
15762 }
15763 153408 }
15764 else
15765 {
15766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 93768 times.
93768 if(!p_getc(& tempbyte,f))
15767 {
15768 return qe_invalid;
15769 }
15770
15771 93768 temp_mapscr->color = (word) tempbyte;
15772 }
15773
15774
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->enemyflags),f))
15775 {
15776 return qe_invalid;
15777 }
15778
15779
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15780 {
15781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->door[k]),f))
15782 {
15783 return qe_invalid;
15784
15785 }
15786 988704 }
15787
15788
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
15789 {
15790
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
15791 {
15792 return qe_invalid;
15793 }
15794
15795 93768 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15796
15797
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15798 {
15799 for(int32_t i=1; i<4; i++)
15800 {
15801 if(!p_getc(&(tempbyte),f))
15802 {
15803 return qe_invalid;
15804 }
15805
15806 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15807 }
15808 }
15809 else
15810 {
15811 93768 temp_mapscr->tilewarpdmap[1]=0;
15812 93768 temp_mapscr->tilewarpdmap[2]=0;
15813 93768 temp_mapscr->tilewarpdmap[3]=0;
15814 }
15815 93768 }
15816 else
15817 {
15818
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
15819 {
15820
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15821 {
15822 return qe_invalid;
15823 }
15824 613632 }
15825 }
15826
15827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15828 {
15829 return qe_invalid;
15830 }
15831
15832
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15833 {
15834
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15835 {
15836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15837 {
15838 return qe_invalid;
15839 }
15840 460224 }
15841 153408 }
15842 else
15843 {
15844 93768 temp_mapscr->tilewarpscr[1]=0;
15845 93768 temp_mapscr->tilewarpscr[2]=0;
15846 93768 temp_mapscr->tilewarpscr[3]=0;
15847 }
15848
15849
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15850 {
15851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15852 {
15853 return qe_invalid;
15854 }
15855 153408 }
15856 else
15857 {
15858 93768 temp_mapscr->tilewarpoverlayflags=0;
15859 }
15860
15861
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->exitdir),f))
15862 {
15863 return qe_invalid;
15864 }
15865
15866
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
15867 {
15868
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&tempbyte,f))
15869 {
15870 return qe_invalid;
15871 }
15872
15873 6864 }
15874
15875
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15876 {
15877 if(!p_getc(&padding,f))
15878 {
15879 return qe_invalid;
15880 }
15881 }
15882
15883
2/2
✓ Branch 0 taken 2471760 times.
✓ Branch 1 taken 247176 times.
2718936 for(int32_t k=0; k<10; k++)
15884 {
15885 /*
15886 if (!temp_mapscr->enemy[k])
15887 {
15888 continue;
15889 }
15890 */
15891
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15892 {
15893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 68640 times.
68640 if(!p_getc(&tempbyte,f))
15894 {
15895 return qe_invalid;
15896 }
15897
15898 68640 temp_mapscr->enemy[k]=tempbyte;
15899 68640 }
15900 else
15901 {
15902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2403120 times.
2403120 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15903 {
15904 return qe_invalid;
15905 }
15906 }
15907
15908
3/6
✓ Branch 0 taken 2403120 times.
✓ Branch 1 taken 68640 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2403120 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
2471760 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15909 {
15910 //using enumerations here is dangerous
15911 //very easy to break old quests -DD
15912
2/2
✓ Branch 0 taken 788 times.
✓ Branch 1 taken 67852 times.
68640 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15913 {
15914 788 temp_mapscr->enemy[k]+=5;
15915 788 }
15916
2/2
✓ Branch 0 taken 67812 times.
✓ Branch 1 taken 40 times.
67852 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15917 {
15918 40 temp_mapscr->enemy[k]+=1;
15919 40 }
15920 68640 }
15921
15922
2/2
✓ Branch 0 taken 1534080 times.
✓ Branch 1 taken 937680 times.
2471760 if(version < 9)
15923 {
15924
2/2
✓ Branch 0 taken 856505 times.
✓ Branch 1 taken 81175 times.
937680 if(temp_mapscr->enemy[k]>0)
15925 {
15926 81175 temp_mapscr->enemy[k]+=10;
15927 81175 }
15928 937680 }
15929 //don't read in any invalid data
15930
2/2
✓ Branch 0 taken 2471670 times.
✓ Branch 1 taken 90 times.
2471760 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15931 {
15932 90 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15933 90 temp_mapscr->enemy[k] = 0;
15934 90 }
15935 2471760 }
15936
15937
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->pattern),f))
15938 {
15939 return qe_invalid;
15940 }
15941
15942
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15943 {
15944 return qe_invalid;
15945 }
15946
15947
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15948 {
15949
2/2
✓ Branch 0 taken 460224 times.
✓ Branch 1 taken 153408 times.
613632 for(int32_t i=1; i<4; i++)
15950 {
15951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15952 {
15953 return qe_invalid;
15954 }
15955 460224 }
15956 153408 }
15957 else
15958 {
15959 93768 temp_mapscr->sidewarptype[1]=0;
15960 93768 temp_mapscr->sidewarptype[2]=0;
15961 93768 temp_mapscr->sidewarptype[3]=0;
15962 }
15963
15964
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version >= 15)
15965 {
15966
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15967 {
15968 return qe_invalid;
15969 }
15970 153408 }
15971 else
15972 {
15973 93768 temp_mapscr->sidewarpoverlayflags=0;
15974 }
15975
15976
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15977 {
15978 return qe_invalid;
15979 }
15980
15981
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15982 {
15983 return qe_invalid;
15984 }
15985
15986
2/2
✓ Branch 0 taken 988704 times.
✓ Branch 1 taken 247176 times.
1235880 for(int32_t k=0; k<4; k++)
15987 {
15988
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 988704 times.
988704 if(!p_getc(&(temp_mapscr->path[k]),f))
15989 {
15990 return qe_invalid;
15991 }
15992 988704 }
15993
15994
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15995 {
15996 return qe_invalid;
15997 }
15998
15999
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16000 {
16001
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 460224 times.
613632 for(int32_t i=1; i<4; i++)
16002 {
16003
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 460224 times.
460224 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16004 {
16005 return qe_invalid;
16006 }
16007 460224 }
16008 153408 }
16009 else
16010 {
16011 93768 temp_mapscr->sidewarpscr[1]=0;
16012 93768 temp_mapscr->sidewarpscr[2]=0;
16013 93768 temp_mapscr->sidewarpscr[3]=0;
16014 }
16015
16016
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version <= 11)
16017 {
16018
1/2
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
93768 if(!p_getc(&(tempbyte),f))
16019 {
16020 return qe_invalid;
16021 }
16022
16023 93768 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
16024
16025
2/6
✓ Branch 0 taken 93768 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
93768 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16026 {
16027 for(int32_t i=1; i<4; i++)
16028 {
16029 if(!p_getc(&(tempbyte),f))
16030 {
16031 return qe_invalid;
16032 }
16033
16034 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
16035 }
16036 }
16037 else
16038 {
16039 93768 temp_mapscr->sidewarpdmap[1]=0;
16040 93768 temp_mapscr->sidewarpdmap[2]=0;
16041 93768 temp_mapscr->sidewarpdmap[3]=0;
16042 }
16043 93768 }
16044 else
16045 {
16046
2/2
✓ Branch 0 taken 613632 times.
✓ Branch 1 taken 153408 times.
767040 for(int32_t i=0; i<4; i++)
16047 {
16048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 613632 times.
613632 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16049 {
16050 return qe_invalid;
16051 }
16052 613632 }
16053 }
16054
16055
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16056 {
16057
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16058 {
16059 return qe_invalid;
16060 }
16061 153408 }
16062 93768 else temp_mapscr->sidewarpindex = 0;
16063
16064
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_igetw(&(temp_mapscr->undercombo),f))
16065 {
16066 return qe_invalid;
16067 }
16068
16069
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
247176 if(Header->zelda_version < 0x193)
16070 {
16071
1/2
✓ Branch 0 taken 6864 times.
✗ Branch 1 not taken.
6864 if(!p_getc(&(temp_mapscr->old_cpage),f))
16072 {
16073 return qe_invalid;
16074 }
16075 6864 }
16076
16077
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
16078 {
16079 return qe_invalid;
16080 }
16081
16082
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_igetw(&(temp_mapscr->catchall),f))
16083 {
16084 return qe_invalid;
16085 }
16086
16087
1/2
✓ Branch 0 taken 247176 times.
✗ Branch 1 not taken.
247176 if(!p_getc(&(temp_mapscr->flags),f))
16088 {
16089 return qe_invalid;
16090 }
16091
16092
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags2),f))
16093 {
16094 return qe_invalid;
16095 }
16096
16097
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(!p_getc(&(temp_mapscr->flags3),f))
16098 {
16099 return qe_invalid;
16100 }
16101
16102
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
16103 //if (version>2)
16104 {
16105
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags4),f))
16106 {
16107 return qe_invalid;
16108 }
16109 153408 }
16110
16111
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
16112 {
16113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags5),f))
16114 {
16115 return qe_invalid;
16116 }
16117
16118
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->noreset),f))
16119 {
16120 return qe_invalid;
16121 }
16122
16123
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->nocarry),f))
16124 {
16125 return qe_invalid;
16126 }
16127
16128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(temp_mapscr->flags5&32)
16129 {
16130 temp_mapscr->flags5 &= ~32;
16131 temp_mapscr->noreset |= 48;
16132 }
16133
16134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(version<8)
16135 {
16136 if(temp_mapscr->noreset&1)
16137 {
16138 temp_mapscr->noreset|=8192;
16139 }
16140
16141 if(temp_mapscr->nocarry&1)
16142 {
16143 temp_mapscr->nocarry|=8192;
16144 temp_mapscr->nocarry&=~1;
16145 }
16146 }
16147 153408 }
16148 else
16149 {
16150 93768 temp_mapscr->flags5 = 0;
16151 93768 temp_mapscr->noreset = 0;
16152 93768 temp_mapscr->nocarry = 0;
16153 }
16154
16155
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
16156 {
16157
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags6),f))
16158 {
16159 return qe_invalid;
16160 }
16161 153408 }
16162
16163
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>5)
16164 {
16165
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags7),f))
16166 {
16167 return qe_invalid;
16168 }
16169
16170
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags8),f))
16171 {
16172 return qe_invalid;
16173 }
16174
16175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->flags9),f))
16176 {
16177 return qe_invalid;
16178 }
16179
16180
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->flags10),f))
16181 {
16182 return qe_invalid;
16183 }
16184
16185
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->csensitive),f))
16186 {
16187 return qe_invalid;
16188 }
16189 153408 }
16190 else
16191 {
16192 93768 temp_mapscr->csensitive=1;
16193 }
16194
16195
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<14) // August 2007: screen SFX added
16196 {
16197
2/2
✓ Branch 0 taken 93668 times.
✓ Branch 1 taken 100 times.
93768 if(temp_mapscr->flags&8) //fROAR
16198 {
16199 100 temp_mapscr->bosssfx=
16200
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 91 times.
100 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
16201 91 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
16202 WAV_ROAR;
16203 100 }
16204
16205
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 93677 times.
93768 if(temp_mapscr->flags&128) //fSEA
16206 {
16207 91 temp_mapscr->oceansfx=WAV_SEA;
16208 91 }
16209
16210 93768 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
16211 ? 0 : WAV_SECRET;
16212
16213 93768 temp_mapscr->flags3 &= ~66; //64|2
16214 93768 temp_mapscr->flags2 &= ~32;
16215 93768 temp_mapscr->flags &= ~136; // 128|8
16216 93768 }
16217 else
16218 {
16219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->oceansfx),f))
16220 {
16221 return qe_invalid;
16222 }
16223
16224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->bosssfx),f))
16225 {
16226 return qe_invalid;
16227 }
16228
16229
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->secretsfx),f))
16230 {
16231 return qe_invalid;
16232 }
16233 }
16234
16235
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version<15) // October 2007: another SFX
16236 {
16237 93768 temp_mapscr->holdupsfx=WAV_PICKUP;
16238 93768 }
16239 else
16240 {
16241
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16242 {
16243 return qe_invalid;
16244 }
16245 }
16246
16247
16248
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16249 {
16250
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16251 {
16252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16253 {
16254 return qe_invalid;
16255 }
16256 1441872 }
16257
16258
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 1441872 times.
1682184 for(int32_t k=0; k<6; k++)
16259 {
16260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16261 {
16262 return qe_invalid;
16263 }
16264 1441872 }
16265 240312 }
16266
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
6864 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
16267 {
16268 if(!p_getc(&(temp_mapscr->layermap[2]),f))
16269 {
16270 return qe_invalid;
16271 }
16272
16273 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
16274 {
16275 return qe_invalid;
16276 }
16277
16278 if(!p_getc(&(temp_mapscr->layermap[4]),f))
16279 {
16280 return qe_invalid;
16281 }
16282
16283 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
16284
16285 {
16286 return qe_invalid;
16287 }
16288 }
16289
16290
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>149))
16291 {
16292 for(int32_t k=0; k<6; k++)
16293 {
16294 if(!p_getc(&tempbyte,f)) //layerxsize
16295 {
16296 return qe_invalid;
16297 }
16298 }
16299
16300 for(int32_t k=0; k<6; k++)
16301 {
16302 if(!p_getc(&tempbyte,f)) //layerxspeed
16303 {
16304 return qe_invalid;
16305 }
16306 }
16307
16308 for(int32_t k=0; k<6; k++)
16309 {
16310 if(!p_getc(&tempbyte,f)) //layerxdelay
16311 {
16312 return qe_invalid;
16313 }
16314 }
16315
16316 for(int32_t k=0; k<6; k++)
16317 {
16318 if(!p_getc(&tempbyte,f)) //layerysize
16319 {
16320 return qe_invalid;
16321 }
16322 }
16323
16324 for(int32_t k=0; k<6; k++)
16325 {
16326 if(!p_getc(&tempbyte,f)) //layeryspeed
16327 {
16328 return qe_invalid;
16329 }
16330 }
16331
16332 for(int32_t k=0; k<6; k++)
16333 {
16334 if(!p_getc(&tempbyte,f)) //layerydelay
16335 {
16336 return qe_invalid;
16337 }
16338 }
16339 }
16340
16341
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
16342 {
16343
2/2
✓ Branch 0 taken 1441872 times.
✓ Branch 1 taken 240312 times.
1682184 for(int32_t k=0; k<6; k++)
16344 {
16345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1441872 times.
1441872 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16346 {
16347 return qe_invalid;
16348 }
16349 1441872 }
16350 240312 }
16351
16352
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16353 {
16354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 if((Header->zelda_version == 0x192)&&(Header->build>153))
16355 {
16356 if(!p_getc(&padding,f))
16357 {
16358 return qe_invalid;
16359 }
16360 }
16361
16362
1/2
✓ Branch 0 taken 240312 times.
✗ Branch 1 not taken.
240312 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16363 {
16364 return qe_invalid;
16365 }
16366 240312 }
16367
16368
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
16369 {
16370 6864 extras=15;
16371 6864 }
16372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
16373 {
16374 extras=11;
16375 }
16376
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<150))
16377 {
16378 extras=32;
16379 }
16380
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16381 {
16382 extras=64;
16383 }
16384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
240312 else if(Header->zelda_version < 0x193)
16385 {
16386 extras=62;
16387 }
16388 else
16389
16390 {
16391 240312 extras=0;
16392 }
16393
16394
2/2
✓ Branch 0 taken 102960 times.
✓ Branch 1 taken 247176 times.
350136 for(int32_t k=0; k<extras; k++)
16395 {
16396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102960 times.
102960 if(!p_getc(&tempbyte,f)) //extra[k]
16397 {
16398 return qe_invalid;
16399 }
16400 102960 }
16401
16402
3/6
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93768 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
16403 //if (version>3)
16404 {
16405
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_getc(&(temp_mapscr->nextmap),f))
16406 {
16407 return qe_invalid;
16408 }
16409
16410
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->nextscr),f))
16411 {
16412 return qe_invalid;
16413 }
16414 153408 }
16415 else
16416 {
16417 93768 temp_mapscr->nextmap=0;
16418 93768 temp_mapscr->nextscr=0;
16419 }
16420
16421
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16422 {
16423 6864 secretcombos=20;
16424 6864 }
16425
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
240312 else if((Header->zelda_version == 0x192)&&(Header->build<154))
16426 {
16427 secretcombos=256;
16428 }
16429 else
16430 {
16431 240312 secretcombos=128;
16432 }
16433
16434
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16435 {
16436
2/2
✓ Branch 0 taken 137280 times.
✓ Branch 1 taken 6864 times.
144144 for(int32_t k=0; k<secretcombos; k++)
16437 {
16438
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(!p_getc(&tempbyte,f))
16439 {
16440 return qe_invalid;
16441 }
16442
16443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137280 times.
137280 if(k<128)
16444 {
16445 137280 temp_mapscr->secretcombo[k]=tempbyte;
16446 137280 }
16447 137280 }
16448 6864 }
16449 else
16450 {
16451
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16452 {
16453
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16454 {
16455 return qe_invalid;
16456 }
16457
16458 30759936 }
16459 }
16460
16461
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16462 {
16463
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16464 {
16465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16466 {
16467 return qe_invalid;
16468 }
16469 30759936 }
16470
16471
2/2
✓ Branch 0 taken 30759936 times.
✓ Branch 1 taken 240312 times.
31000248 for(int32_t k=0; k<128; k++)
16472 {
16473
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30759936 times.
30759936 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16474 {
16475 return qe_invalid;
16476 }
16477 30759936 }
16478 240312 }
16479
16480
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16481 {
16482 if(!p_getc(&padding,f))
16483 {
16484 return qe_invalid;
16485 }
16486 }
16487
16488 247176 const int32_t _mapsSize = (temp_map->tileWidth*temp_map->tileHeight);
16489
16490
2/2
✓ Branch 0 taken 43502976 times.
✓ Branch 1 taken 247176 times.
43750152 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16491 {
16492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43502976 times.
43502976 if(!p_igetw(&(temp_mapscr->data[k]),f))
16493 {
16494 return qe_invalid;
16495 }
16496 43502976 }
16497
16498
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16499 {
16500 if(!p_getc(&padding,f))
16501 {
16502 return qe_invalid;
16503 }
16504
16505 if(!p_getc(&padding,f))
16506 {
16507 return qe_invalid;
16508 }
16509 }
16510
16511
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16512 {
16513
2/2
✓ Branch 0 taken 42294912 times.
✓ Branch 1 taken 240312 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16514 {
16515
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16516 {
16517 return qe_invalid;
16518 }
16519
16520
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
42294912 if((Header->zelda_version == 0x192)&&(Header->build<24))
16521 {
16522 if(!p_getc(&tempbyte,f))
16523 {
16524 return qe_invalid;
16525 }
16526
16527 if(!p_getc(&tempbyte,f))
16528 {
16529 return qe_invalid;
16530 }
16531
16532 if(!p_getc(&tempbyte,f))
16533 {
16534 return qe_invalid;
16535 }
16536 }
16537 42294912 }
16538 240312 }
16539
16540
3/6
✓ Branch 0 taken 6864 times.
✓ Branch 1 taken 240312 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6864 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16541 {
16542
2/2
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 42294912 times.
42535224 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16543 {
16544
16545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42294912 times.
42294912 if(!p_getc(&(temp_mapscr->cset[k]),f))
16546 {
16547 return qe_invalid;
16548 }
16549 42294912 }
16550 240312 }
16551
16552
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16553 {
16554 6864 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16555 6864 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16556 6864 }
16557
16558
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16559 {
16560 6864 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16561 6864 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16562 6864 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16563 6864 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16564 6864 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16565 6864 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16566 6864 }
16567
16568
3/6
✓ Branch 0 taken 240312 times.
✓ Branch 1 taken 6864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 240312 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
247176 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16569 {
16570
2/2
✓ Branch 0 taken 1208064 times.
✓ Branch 1 taken 6864 times.
1214928 for(int32_t k=0; k<(temp_map->tileWidth*temp_map->tileHeight); k++)
16571 {
16572
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version == 0x192)&&(Header->build>149))
16573 {
16574 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16575 {
16576 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16577 }
16578 }
16579 else
16580 {
16581
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1208064 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
1208064 if((Header->zelda_version < 0x192)||
16582 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16583 {
16584 1208064 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16585 1208064 }
16586
16587 1208064 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16588 }
16589
16590 1208064 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16591 1208064 }
16592 6864 }
16593
16594 /*if(version>12)
16595 {
16596 if(!p_getc(&(temp_mapscr->scrWidth),f))
16597 {
16598 return qe_invalid;
16599 }
16600 if(!p_getc(&(temp_mapscr->scrHeight),f))
16601 {
16602 return qe_invalid;
16603 }
16604 }*/
16605
16606
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>4)
16607 {
16608
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16609 {
16610 return qe_invalid;
16611 }
16612 153408 }
16613 else
16614 {
16615 93768 temp_mapscr->screen_midi = -1;
16616 }
16617
16618
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version>=17)
16619 {
16620
1/2
✓ Branch 0 taken 153408 times.
✗ Branch 1 not taken.
153408 if(!p_getc(&(temp_mapscr->lens_layer),f))
16621 {
16622 return qe_invalid;
16623 }
16624 153408 }
16625 else
16626 {
16627 93768 temp_mapscr->lens_layer = llNORMAL;
16628 }
16629
16630
2/2
✓ Branch 0 taken 93768 times.
✓ Branch 1 taken 153408 times.
247176 if(version>6)
16631 {
16632 dword bits;
16633
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 153408 times.
153408 if(!p_igetl(&bits,f))
16634 {
16635 return qe_invalid;
16636 }
16637
16638 int32_t m;
16639 float tempfloat;
16640 word tempw;
16641 153408 temp_mapscr->ffcCountMarkDirty();
16642
16643
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 4909056 times.
5062464 for(m=0; m<32; m++)
16644 {
16645 4909056 ffcdata& tempffc = temp_mapscr->ffcs[m];
16646 4909056 tempffc.clear();
16647
2/2
✓ Branch 0 taken 4886067 times.
✓ Branch 1 taken 22989 times.
4909056 if((bits>>m)&1)
16648 {
16649
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetw(&tempw,f))
16650 {
16651 return qe_invalid;
16652 }
16653 22989 tempffc.setData(tempw);
16654
16655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.cset),f))
16656 {
16657 return qe_invalid;
16658 }
16659
16660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.delay),f))
16661 {
16662 return qe_invalid;
16663 }
16664
16665
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(version < 9)
16666 {
16667 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16668 {
16669 return qe_invalid;
16670 }
16671
16672 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16673
16674 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16675 {
16676 return qe_invalid;
16677 }
16678
16679 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16680
16681 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16682 {
16683 return qe_invalid;
16684 }
16685
16686 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16687
16688 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16689 {
16690 return qe_invalid;
16691 }
16692
16693 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16694
16695 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16696 {
16697 return qe_invalid;
16698 }
16699
16700 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16701
16702 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16703 {
16704 return qe_invalid;
16705 }
16706
16707 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16708 }
16709 else
16710 {
16711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.x),f))
16712 {
16713 return qe_invalid;
16714 }
16715
16716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.y),f))
16717 {
16718 return qe_invalid;
16719 }
16720
16721
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(!p_igetzf(&(tempffc.vx),f))
16722 {
16723 return qe_invalid;
16724 }
16725
16726
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.vy),f))
16727 {
16728 return qe_invalid;
16729 }
16730
16731
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ax),f))
16732 {
16733 return qe_invalid;
16734 }
16735
16736
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetzf(&(tempffc.ay),f))
16737 {
16738 return qe_invalid;
16739 }
16740 }
16741
16742
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempffc.link),f))
16743 {
16744 return qe_invalid;
16745 }
16746
16747
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>7)
16748 {
16749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16750 {
16751 return qe_invalid;
16752 }
16753
16754 22989 tempffc.hit_width = (tempbyte&0x3F)+1;
16755 22989 tempffc.txsz = (tempbyte>>6)+1;
16756
16757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&tempbyte,f))
16758 {
16759 return qe_invalid;
16760 }
16761
16762 22989 tempffc.hit_height = (tempbyte&0x3F)+1;
16763 22989 tempffc.tysz = (tempbyte>>6)+1;
16764
16765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.flags),f))
16766 {
16767 return qe_invalid;
16768 }
16769 22989 }
16770 else
16771 {
16772 tempffc.hit_width=16;
16773 tempffc.hit_height=16;
16774 tempffc.txsz=1;
16775 tempffc.tysz=1;
16776 tempffc.flags=0;
16777 }
16778
16779 22989 tempffc.updateSolid();
16780
16781
16782
4/6
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20969 times.
✓ Branch 3 taken 2020 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 20969 times.
22989 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16783 {
16784 tempffc.flags|=ffIGNOREHOLDUP;
16785 }
16786
16787
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>9)
16788 {
16789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetw(&(tempffc.script),f))
16790 {
16791 return qe_invalid;
16792 }
16793 22989 }
16794 else
16795 {
16796 tempffc.script=0;
16797 }
16798
16799
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version>10)
16800 {
16801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[0]),f))
16802 {
16803 return qe_invalid;
16804 }
16805
16806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[1]),f))
16807 {
16808 return qe_invalid;
16809 }
16810
16811
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[2]),f))
16812 {
16813 return qe_invalid;
16814 }
16815
16816
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[3]),f))
16817 {
16818 return qe_invalid;
16819 }
16820
16821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[4]),f))
16822 {
16823 return qe_invalid;
16824 }
16825
16826
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[5]),f))
16827 {
16828 return qe_invalid;
16829 }
16830
16831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[6]),f))
16832 {
16833 return qe_invalid;
16834 }
16835
16836
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_igetl(&(tempffc.initd[7]),f))
16837 {
16838 return qe_invalid;
16839 }
16840
16841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16842 {
16843 return qe_invalid;
16844 }
16845
16846 22989 tempffc.inita[0]=tempbyte*10000;
16847
16848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22989 times.
22989 if(!p_getc(&(tempbyte),f))
16849 {
16850 return qe_invalid;
16851 }
16852
16853 22989 tempffc.inita[1]=tempbyte*10000;
16854 22989 }
16855 else
16856 {
16857 tempffc.inita[0] = 10000;
16858 tempffc.inita[1] = 10000;
16859 }
16860
16861
1/2
✓ Branch 0 taken 22989 times.
✗ Branch 1 not taken.
22989 if(version <= 11)
16862 {
16863 fixffcs=true;
16864 }
16865 22989 }
16866 4909056 }
16867
2/2
✓ Branch 0 taken 14727168 times.
✓ Branch 1 taken 153408 times.
14880576 for(m = 32; m < MAXFFCS; ++m)
16868 {
16869 14727168 temp_mapscr->ffcs[m].clear();
16870 14727168 }
16871 153408 }
16872
16873 //add in the new whistle flags
16874
2/2
✓ Branch 0 taken 153408 times.
✓ Branch 1 taken 93768 times.
247176 if(version<13)
16875 {
16876
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 93749 times.
93768 if(temp_mapscr->flags & fWHISTLE)
16877 {
16878 19 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16879 19 }
16880 93768 }
16881
16882 //2.55 starts here
16883
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 19 && Header->zelda_version > 0x253 )
16884 {
16885
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16886 {
16887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16888 {
16889 return qe_invalid;
16890 }
16891 137360 }
16892
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16893 {
16894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16895 {
16896 return qe_invalid;
16897 }
16898 137360 }
16899
2/2
✓ Branch 0 taken 137360 times.
✓ Branch 1 taken 13736 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16900 {
16901
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16902 {
16903 return qe_invalid;
16904 }
16905 137360 }
16906
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 137360 times.
151096 for ( int32_t q = 0; q < 10; q++ )
16907 {
16908
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137360 times.
137360 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16909 {
16910 return qe_invalid;
16911 }
16912 137360 }
16913 13736 }
16914
3/4
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 233440 times.
247176 if ( version < 19 && Header->zelda_version > 0x253 )
16915 {
16916 for ( int32_t q = 0; q < 10; q++ )
16917 {
16918 temp_mapscr->npcstrings[q] = 0;
16919 temp_mapscr->new_items[q] = 0;
16920 temp_mapscr->new_item_x[q] = 0;
16921 temp_mapscr->new_item_y[q] = 0;
16922 }
16923 }
16924
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 20 && Header->zelda_version > 0x253 )
16925 {
16926
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_igetw(&(temp_mapscr->script),f))
16927 {
16928 return qe_invalid;
16929 }
16930
2/2
✓ Branch 0 taken 109888 times.
✓ Branch 1 taken 13736 times.
123624 for ( int32_t q = 0; q < 8; q++)
16931 {
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109888 times.
109888 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16933 {
16934 return qe_invalid;
16935 }
16936 109888 }
16937 13736 }
16938
2/2
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
247176 if ( version < 20 )
16939 {
16940 233440 temp_mapscr->script = 0;
16941
2/2
✓ Branch 0 taken 1867520 times.
✓ Branch 1 taken 233440 times.
2100960 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16942 233440 }
16943
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 21 && Header->zelda_version > 0x253 )
16944 {
16945
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->preloadscript),f))
16946 {
16947 return qe_invalid;
16948 }
16949 13736 }
16950
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 21 )
16951 {
16952 233440 temp_mapscr->preloadscript = 0;
16953 233440 }
16954 //all builds with version > 20 need this. -Z
16955
16956
3/4
✓ Branch 0 taken 13736 times.
✓ Branch 1 taken 233440 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 13736 times.
247176 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16957 {
16958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13736 times.
13736 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16959 {
16960 return qe_invalid;
16961 }
16962
1/2
✓ Branch 0 taken 13736 times.
✗ Branch 1 not taken.
13736 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16963 {
16964 return qe_invalid;
16965 }
16966 13736 }
16967
2/2
✓ Branch 0 taken 233440 times.
✓ Branch 1 taken 13736 times.
247176 if ( version < 22 )
16968 {
16969 233440 temp_mapscr->hidelayers = 0;
16970 233440 temp_mapscr->hidescriptlayers = 0;
16971 233440 }
16972
16973 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16974 //May be any version before 2.11. -Z
16975 /* --not the roar, the HIT SFX
16976 if ( Header->zelda_version <= 0x210 )
16977 {
16978 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16979 {
16980 temp_mapscr->bosssfx = WAV_ROAR;
16981 }
16982 }
16983 */
16984
16985 247176 return 0;
16986 247176 }
16987 263632 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, zcmap *temp_map, word version, int scrind)
16988 {
16989
2/2
✓ Branch 0 taken 247176 times.
✓ Branch 1 taken 16456 times.
263632 if(version < 23)
16990 {
16991 247176 auto ret = readmapscreen_old(f,Header,temp_mapscr,temp_map,version);
16992
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 247176 times.
247176 if(ret) return ret;
16993 247176 }
16994 else
16995 {
16996
1/2
✓ Branch 0 taken 16456 times.
✗ Branch 1 not taken.
16456 if(!p_getc(&(temp_mapscr->valid),f))
16997 return qe_invalid;
16998
2/2
✓ Branch 0 taken 10383 times.
✓ Branch 1 taken 6073 times.
16456 if(!(temp_mapscr->valid & mVALID))
16999 {
17000 10383 int map = scrind/MAPSCRS;
17001 10383 int scr = scrind%MAPSCRS;
17002
4/6
✓ Branch 0 taken 4484 times.
✓ Branch 1 taken 5899 times.
✓ Branch 2 taken 4484 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4484 times.
✗ Branch 5 not taken.
10383 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
17003 {
17004 //Empty screen, apply autolayers
17005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4484 times.
4484 for(int q = 0; q < 6; ++q)
17006 {
17007 auto layermap = map_autolayers[map*6+q];
17008 temp_mapscr->layermap[q] = layermap;
17009 if(layermap)
17010 temp_mapscr->layerscreen[q] = scr;
17011 }
17012 4484 }
17013 10383 return 0;
17014 }
17015 uint32_t scr_has_flags;
17016
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetl(&scr_has_flags,f))
17017 return qe_invalid;
17018
17019
2/2
✓ Branch 0 taken 5329 times.
✓ Branch 1 taken 744 times.
6073 if(scr_has_flags & SCRHAS_ROOMDATA)
17020 {
17021
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->guy),f))
17022 return qe_invalid;
17023
2/2
✓ Branch 0 taken 684 times.
✓ Branch 1 taken 60 times.
744 if(version > 26)
17024 {
17025
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetl(&(temp_mapscr->guytile),f))
17026 return qe_invalid;
17027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 684 times.
684 if(!p_getc(&(temp_mapscr->guycs),f))
17028 return qe_invalid;
17029
1/2
✓ Branch 0 taken 684 times.
✗ Branch 1 not taken.
684 if(!p_igetw(&(temp_mapscr->roomflags),f))
17030 return qe_invalid;
17031 684 }
17032 else
17033 {
17034 60 temp_mapscr->guytile = -1; //signal to use default guy values
17035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
60 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
17036
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
60 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
17037 }
17038
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->str),f))
17039 return qe_invalid;
17040
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_getc(&(temp_mapscr->room),f))
17041 return qe_invalid;
17042
1/2
✓ Branch 0 taken 744 times.
✗ Branch 1 not taken.
744 if(!p_igetw(&(temp_mapscr->catchall),f))
17043 return qe_invalid;
17044 744 }
17045
2/2
✓ Branch 0 taken 5950 times.
✓ Branch 1 taken 123 times.
6073 if(scr_has_flags & SCRHAS_ITEM)
17046 {
17047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->item),f))
17048 return qe_invalid;
17049
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->hasitem),f))
17050 return qe_invalid;
17051
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 123 times.
123 if(!p_getc(&(temp_mapscr->itemx),f))
17052 return qe_invalid;
17053
1/2
✓ Branch 0 taken 123 times.
✗ Branch 1 not taken.
123 if(!p_getc(&(temp_mapscr->itemy),f))
17054 return qe_invalid;
17055 123 }
17056
2/2
✓ Branch 0 taken 5716 times.
✓ Branch 1 taken 357 times.
6073 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
17057 {
17058
1/2
✓ Branch 0 taken 357 times.
✗ Branch 1 not taken.
357 if(!p_igetw(&temp_mapscr->warpreturnc,f))
17059 return qe_invalid;
17060 357 }
17061
2/2
✓ Branch 0 taken 5829 times.
✓ Branch 1 taken 244 times.
6073 if(scr_has_flags & SCRHAS_TWARP)
17062 {
17063
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17064 {
17065
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
17066 return qe_invalid;
17067 976 }
17068
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17069 {
17070
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
17071 return qe_invalid;
17072 976 }
17073
2/2
✓ Branch 0 taken 976 times.
✓ Branch 1 taken 244 times.
1220 for(int32_t i=0; i<4; i++)
17074 {
17075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 976 times.
976 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
17076 return qe_invalid;
17077 976 }
17078
1/2
✓ Branch 0 taken 244 times.
✗ Branch 1 not taken.
244 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
17079 return qe_invalid;
17080 244 }
17081
2/2
✓ Branch 0 taken 5934 times.
✓ Branch 1 taken 139 times.
6073 if(scr_has_flags & SCRHAS_SWARP)
17082 {
17083
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17084 {
17085
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
17086 return qe_invalid;
17087 556 }
17088
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17089 {
17090
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
17091 return qe_invalid;
17092 556 }
17093
2/2
✓ Branch 0 taken 556 times.
✓ Branch 1 taken 139 times.
695 for(int32_t i=0; i<4; i++)
17094 {
17095
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 556 times.
556 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
17096 return qe_invalid;
17097 556 }
17098
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
17099 return qe_invalid;
17100
1/2
✓ Branch 0 taken 139 times.
✗ Branch 1 not taken.
139 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
17101 return qe_invalid;
17102 139 }
17103
2/2
✓ Branch 0 taken 5636 times.
✓ Branch 1 taken 437 times.
6073 if(scr_has_flags & SCRHAS_WARPRET)
17104 {
17105
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17106 {
17107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
17108 return qe_invalid;
17109 1748 }
17110
2/2
✓ Branch 0 taken 1748 times.
✓ Branch 1 taken 437 times.
2185 for(int32_t i=0; i<4; i++)
17111 {
17112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1748 times.
1748 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
17113 return qe_invalid;
17114 1748 }
17115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 437 times.
437 if(!p_getc(&(temp_mapscr->warparrivalx),f))
17116 return qe_invalid;
17117
1/2
✓ Branch 0 taken 437 times.
✗ Branch 1 not taken.
437 if(!p_getc(&(temp_mapscr->warparrivaly),f))
17118 return qe_invalid;
17119 437 }
17120
2/2
✓ Branch 0 taken 4945 times.
✓ Branch 1 taken 1128 times.
6073 if(scr_has_flags & SCRHAS_LAYERS)
17121 {
17122
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17123 {
17124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layermap[k]),f))
17125 return qe_invalid;
17126 6768 }
17127
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17128 {
17129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
17130 return qe_invalid;
17131 6768 }
17132
2/2
✓ Branch 0 taken 6768 times.
✓ Branch 1 taken 1128 times.
7896 for(int32_t k=0; k<6; k++)
17133 {
17134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6768 times.
6768 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
17135 return qe_invalid;
17136 6768 }
17137
1/2
✓ Branch 0 taken 1128 times.
✗ Branch 1 not taken.
1128 if(!p_getc(&(temp_mapscr->hidelayers),f))
17138 return qe_invalid;
17139
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1128 times.
1128 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
17140 return qe_invalid;
17141 1128 }
17142
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MAZE)
17143 {
17144 for(int32_t k=0; k<4; k++)
17145 {
17146 if(!p_getc(&(temp_mapscr->path[k]),f))
17147 return qe_invalid;
17148 }
17149 if(!p_getc(&(temp_mapscr->exitdir),f))
17150 return qe_invalid;
17151 }
17152
2/2
✓ Branch 0 taken 5916 times.
✓ Branch 1 taken 157 times.
6073 if(scr_has_flags & SCRHAS_D_S_U)
17153 {
17154
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
17155 return qe_invalid;
17156
2/2
✓ Branch 0 taken 628 times.
✓ Branch 1 taken 157 times.
785 for(int32_t k=0; k<4; k++)
17157 {
17158
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 628 times.
628 if(!p_getc(&(temp_mapscr->door[k]),f))
17159 return qe_invalid;
17160 628 }
17161
17162
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairx),f))
17163 return qe_invalid;
17164
17165
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_getc(&(temp_mapscr->stairy),f))
17166 return qe_invalid;
17167
1/2
✓ Branch 0 taken 157 times.
✗ Branch 1 not taken.
157 if(!p_igetw(&(temp_mapscr->undercombo),f))
17168 return qe_invalid;
17169
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 157 times.
157 if(!p_getc(&(temp_mapscr->undercset),f))
17170 return qe_invalid;
17171 157 }
17172
2/2
✓ Branch 0 taken 5637 times.
✓ Branch 1 taken 436 times.
6073 if(scr_has_flags & SCRHAS_FLAGS)
17173 {
17174
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags),f))
17175 return qe_invalid;
17176
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags2),f))
17177 return qe_invalid;
17178
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags3),f))
17179 return qe_invalid;
17180
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags4),f))
17181 return qe_invalid;
17182
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags5),f))
17183 return qe_invalid;
17184
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags6),f))
17185 return qe_invalid;
17186
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags7),f))
17187 return qe_invalid;
17188
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags8),f))
17189 return qe_invalid;
17190
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->flags9),f))
17191 return qe_invalid;
17192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 436 times.
436 if(!p_getc(&(temp_mapscr->flags10),f))
17193 return qe_invalid;
17194
1/2
✓ Branch 0 taken 436 times.
✗ Branch 1 not taken.
436 if(!p_getc(&(temp_mapscr->enemyflags),f))
17195 return qe_invalid;
17196 436 }
17197
2/2
✓ Branch 0 taken 5694 times.
✓ Branch 1 taken 379 times.
6073 if(scr_has_flags & SCRHAS_ENEMY)
17198 {
17199
2/2
✓ Branch 0 taken 3790 times.
✓ Branch 1 taken 379 times.
4169 for(int32_t k=0; k<10; k++)
17200 {
17201
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3790 times.
3790 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
17202 return qe_invalid;
17203
1/2
✓ Branch 0 taken 3790 times.
✗ Branch 1 not taken.
3790 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
17204 temp_mapscr->enemy[k] = 0;
17205 3790 }
17206
1/2
✓ Branch 0 taken 379 times.
✗ Branch 1 not taken.
379 if(!p_getc(&(temp_mapscr->pattern),f))
17207 return qe_invalid;
17208 379 }
17209
2/2
✓ Branch 0 taken 6040 times.
✓ Branch 1 taken 33 times.
6073 if(scr_has_flags & SCRHAS_CARRY)
17210 {
17211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
33 if(!p_igetw(&(temp_mapscr->noreset),f))
17212 return qe_invalid;
17213
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_igetw(&(temp_mapscr->nocarry),f))
17214 return qe_invalid;
17215
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextmap),f))
17216 return qe_invalid;
17217
1/2
✓ Branch 0 taken 33 times.
✗ Branch 1 not taken.
33 if(!p_getc(&(temp_mapscr->nextscr),f))
17218 return qe_invalid;
17219 33 }
17220
2/2
✓ Branch 0 taken 6004 times.
✓ Branch 1 taken 69 times.
6073 if(scr_has_flags & SCRHAS_SCRIPT)
17221 {
17222
1/2
✓ Branch 0 taken 69 times.
✗ Branch 1 not taken.
69 if(!p_igetw(&(temp_mapscr->script),f))
17223 return qe_invalid;
17224
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
69 if(!p_getc(&(temp_mapscr->preloadscript),f))
17225 return qe_invalid;
17226
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 69 times.
621 for ( int32_t q = 0; q < 8; q++ )
17227 {
17228
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552 times.
552 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
17229 return qe_invalid;
17230 552 }
17231 69 }
17232
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_UNUSED)
17233 {
17234 for ( int32_t q = 0; q < 10; q++ )
17235 {
17236 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
17237 return qe_invalid;
17238 }
17239 for ( int32_t q = 0; q < 10; q++ )
17240 {
17241 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
17242 return qe_invalid;
17243 }
17244 for ( int32_t q = 0; q < 10; q++ )
17245 {
17246 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
17247 return qe_invalid;
17248 }
17249 for ( int32_t q = 0; q < 10; q++ )
17250 {
17251 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
17252 return qe_invalid;
17253 }
17254 }
17255
2/2
✓ Branch 0 taken 5652 times.
✓ Branch 1 taken 421 times.
6073 if(scr_has_flags & SCRHAS_SECRETS)
17256 {
17257
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17258 {
17259
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
17260 return qe_invalid;
17261 53888 }
17262
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17263 {
17264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
17265 return qe_invalid;
17266 53888 }
17267
2/2
✓ Branch 0 taken 53888 times.
✓ Branch 1 taken 421 times.
54309 for(int32_t k=0; k<128; k++)
17268 {
17269
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53888 times.
53888 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
17270 return qe_invalid;
17271 53888 }
17272 421 }
17273
2/2
✓ Branch 0 taken 2945 times.
✓ Branch 1 taken 3128 times.
6073 if(scr_has_flags & SCRHAS_COMBOFLAG)
17274 {
17275
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17276 {
17277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_igetw(&(temp_mapscr->data[k]),f))
17278 return qe_invalid;
17279 550528 }
17280
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17281 {
17282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->sflag[k]),f))
17283 return qe_invalid;
17284 550528 }
17285
2/2
✓ Branch 0 taken 550528 times.
✓ Branch 1 taken 3128 times.
553656 for(int32_t k=0; k<176; ++k)
17286 {
17287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 550528 times.
550528 if(!p_getc(&(temp_mapscr->cset[k]),f))
17288 return qe_invalid;
17289 550528 }
17290 3128 }
17291
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(scr_has_flags & SCRHAS_MISC)
17292 {
17293
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->color),f))
17294 return qe_invalid;
17295
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->csensitive),f))
17296 return qe_invalid;
17297
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->oceansfx),f))
17298 return qe_invalid;
17299
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->bosssfx),f))
17300 return qe_invalid;
17301
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_getc(&(temp_mapscr->secretsfx),f))
17302 return qe_invalid;
17303
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->holdupsfx),f))
17304 return qe_invalid;
17305
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
17306 return qe_invalid;
17307
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(!p_igetw(&(temp_mapscr->screen_midi),f))
17308 return qe_invalid;
17309
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_getc(&(temp_mapscr->lens_layer),f))
17310 return qe_invalid;
17311
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(version > 27)
17312 {
17313 if(!p_getc(&(temp_mapscr->lens_show),f))
17314 return qe_invalid;
17315 if(!p_getc(&(temp_mapscr->lens_hide),f))
17316 return qe_invalid;
17317 }
17318 6073 }
17319 else
17320 {
17321 temp_mapscr->screen_midi = -1;
17322 temp_mapscr->csensitive = 1;
17323 }
17324 //FFC
17325 6073 bool old_ff = version < 25;
17326 6073 dword bits = 0;
17327 6073 word numffc = 32;
17328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6073 times.
6073 if(old_ff)
17329 {
17330 if(!p_igetl(&bits,f))
17331 return qe_invalid;
17332 }
17333 else
17334 {
17335
1/2
✓ Branch 0 taken 6073 times.
✗ Branch 1 not taken.
6073 if(!p_igetw(&numffc,f))
17336 return qe_invalid;
17337 }
17338 byte tempbyte;
17339 word tempw;
17340
4/6
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 6040 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 33 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 33 times.
6073 static ffcdata nil_ffc;
17341 6073 temp_mapscr->ffcCountMarkDirty();
17342
2/2
✓ Branch 0 taken 6073 times.
✓ Branch 1 taken 8316 times.
14389 for(word m = 0; m < numffc; ++m)
17343 {
17344
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 ffcdata& tempffc = (m < MAXFFCS)
17345 8316 ? temp_mapscr->ffcs[m]
17346 : nil_ffc; //sanity
17347 8316 tempffc.clear();
17348
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8316 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8316 if(old_ff && !(bits & (1<<m))) continue;
17349
17350
1/2
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
8316 if(!p_igetw(&tempw,f))
17351 return qe_invalid;
17352
3/4
✓ Branch 0 taken 8316 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1546 times.
✓ Branch 3 taken 6770 times.
8316 if(!old_ff && !tempw) //empty ffc, nothing more to load
17353 6770 continue;
17354 1546 tempffc.setData(tempw);
17355
17356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.cset),f))
17357 return qe_invalid;
17358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.delay),f))
17359 return qe_invalid;
17360
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.x),f))
17361 return qe_invalid;
17362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.y),f))
17363 return qe_invalid;
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vx),f))
17365 return qe_invalid;
17366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetzf(&(tempffc.vy),f))
17367 return qe_invalid;
17368
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ax),f))
17369 return qe_invalid;
17370
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetzf(&(tempffc.ay),f))
17371 return qe_invalid;
17372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.link),f))
17373 return qe_invalid;
17374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(version < 24)
17375 {
17376 if(!p_getc(&tempbyte,f))
17377 return qe_invalid;
17378 tempffc.hit_width = (tempbyte&0x3F)+1;
17379 tempffc.txsz = (tempbyte>>6)+1;
17380 if(!p_getc(&tempbyte,f))
17381 return qe_invalid;
17382 tempffc.hit_height = (tempbyte&0x3F)+1;
17383 tempffc.tysz = (tempbyte>>6)+1;
17384 }
17385 else
17386 {
17387
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_width),f))
17388 return qe_invalid;
17389
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_igetl(&(tempffc.hit_height),f))
17390 return qe_invalid;
17391
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempffc.txsz),f))
17392 return qe_invalid;
17393
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempffc.tysz),f))
17394 return qe_invalid;
17395 }
17396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetl(&(tempffc.flags),f))
17397 return qe_invalid;
17398 1546 tempffc.updateSolid();
17399
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_igetw(&(tempffc.script),f))
17400 return qe_invalid;
17401
2/2
✓ Branch 0 taken 12368 times.
✓ Branch 1 taken 1546 times.
13914 for(auto q = 0; q < 8; ++q)
17402 {
17403
1/2
✓ Branch 0 taken 12368 times.
✗ Branch 1 not taken.
12368 if(!p_igetl(&(tempffc.initd[q]),f))
17404 return qe_invalid;
17405 12368 }
17406
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1546 times.
1546 if(!p_getc(&(tempbyte),f))
17407 return qe_invalid;
17408 1546 tempffc.inita[0]=tempbyte*10000;
17409
17410
1/2
✓ Branch 0 taken 1546 times.
✗ Branch 1 not taken.
1546 if(!p_getc(&(tempbyte),f))
17411 return qe_invalid;
17412 1546 tempffc.inita[1]=tempbyte*10000;
17413 1546 }
17414
2/2
✓ Branch 0 taken 769028 times.
✓ Branch 1 taken 6073 times.
775101 for(word m = numffc; m < MAXFFCS; ++m)
17415 {
17416 769028 temp_mapscr->ffcs[m].clear();
17417 769028 }
17418 //END FFC
17419 }
17420 253249 return 0;
17421 263632 }
17422
17423
17424 129 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17425 {
17426 129 int32_t scr=0;
17427
17428 129 word version=0;
17429 dword dummy;
17430 int32_t screens_to_read;
17431
17432 129 mapscr temp_mapscr;
17433 zcmap temp_map;
17434 word temp_map_count;
17435 dword section_size;
17436
17437
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17438 {
17439 4 screens_to_read=MAPSCRS192b136;
17440 4 }
17441 else
17442 {
17443 125 screens_to_read=MAPSCRS;
17444 }
17445
17446
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
17447 {
17448 //section version info
17449
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&version,f))
17450 {
17451 return qe_invalid;
17452 }
17453
17454 125 FFCore.quest_format[vMaps] = version;
17455
17456 //al_trace("Maps version %d\n", version);
17457
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
17458 {
17459 return qe_invalid;
17460 }
17461
17462 //section size
17463
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
17464 {
17465 return qe_invalid;
17466 }
17467
17468 //finally... section data
17469
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&temp_map_count,f))
17470 {
17471 return 5;
17472 }
17473 125 }
17474 else
17475 {
17476 4 temp_map_count=map_count;
17477 }
17478
17479
2/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
129 if (!(temp_map_count >= 0 && temp_map_count <= MAXMAPS2))
17480 {
17481 return qe_invalid;
17482 }
17483
17484 129 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17485 129 TheMaps.resize(_mapsSize);
17486 129 map_autolayers.clear();
17487 129 map_autolayers.resize(temp_map_count*6);
17488
17489
2/2
✓ Branch 0 taken 264792 times.
✓ Branch 1 taken 129 times.
264921 for(int32_t i(0); i<_mapsSize; i++)
17490 264792 TheMaps[i].zero_memory();
17491
17492 129 memset(ZCMaps, 0, sizeof(zcmap)*MAXMAPS2);
17493
17494 129 temp_mapscr.zero_memory();
17495
17496 { //Is this stuff even needed anymore? Is it used at all? -Em
17497 129 memset(&temp_map, 0, sizeof(zcmap));
17498 129 temp_map.scrResWidth = 256;
17499 129 temp_map.scrResHeight = 224;
17500 129 temp_map.tileWidth = 16;
17501 129 temp_map.tileHeight = 11;
17502 129 temp_map.viewWidth = 256;
17503 129 temp_map.viewHeight = 176;
17504 129 temp_map.viewX = 0;
17505 129 temp_map.viewY = 64;
17506 129 temp_map.subaWidth = 256;
17507 129 temp_map.subaHeight = 168;
17508 129 temp_map.subaTrans = false;
17509 129 temp_map.subpWidth = 256;
17510 129 temp_map.subpHeight = 56;
17511 129 temp_map.subpTrans = false;
17512 }
17513
4/4
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 1947 times.
✓ Branch 2 taken 1947 times.
✓ Branch 3 taken 129 times.
2076 for(int32_t i=0; i<temp_map_count && i<MAXMAPS2; i++)
17514 {
17515 //!TODO Trim fully
17516 1947 memcpy(&ZCMaps[i], &temp_map, sizeof(zcmap));
17517
17518 1947 byte valid=1;
17519
2/2
✓ Branch 0 taken 1819 times.
✓ Branch 1 taken 128 times.
1947 if(version > 22)
17520 {
17521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 128 times.
128 if(!p_getc(&valid,f))
17522 return qe_invalid;
17523 128 }
17524
4/4
✓ Branch 0 taken 1940 times.
✓ Branch 1 taken 7 times.
✓ Branch 2 taken 1902 times.
✓ Branch 3 taken 38 times.
1947 if(valid && version > 25)
17525 {
17526
2/2
✓ Branch 0 taken 228 times.
✓ Branch 1 taken 38 times.
266 for(int q = 0; q < 6; ++q)
17527 {
17528
1/2
✓ Branch 0 taken 228 times.
✗ Branch 1 not taken.
228 if(!p_igetw(&map_autolayers[i*6+q],f))
17529 return qe_invalid;
17530 228 }
17531 38 }
17532
2/2
✓ Branch 0 taken 264584 times.
✓ Branch 1 taken 1947 times.
266531 for(int32_t j=0; j<screens_to_read; j++)
17533 {
17534 264584 scr=i*MAPSCRS+j;
17535 264584 clear_screen(&temp_mapscr);
17536
2/2
✓ Branch 0 taken 952 times.
✓ Branch 1 taken 263632 times.
264584 if(valid)
17537 263632 readmapscreen(f, Header, &temp_mapscr, &temp_map, version, scr);
17538
17539 264584 TheMaps[scr] = temp_mapscr;
17540 264584 }
17541
17542
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17543 {
17544 52 int32_t index = (i*MAPSCRS+132);
17545
17546 52 TheMaps[index]=TheMaps[index-1];
17547
17548 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17549 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17550 52 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17551
17552
2/2
✓ Branch 0 taken 156 times.
✓ Branch 1 taken 52 times.
208 for(int32_t j=133; j<MAPSCRS; j++)
17553 {
17554 156 scr=i*MAPSCRS+j;
17555
17556 156 TheMaps[scr].zero_memory();
17557 156 TheMaps[scr].valid = mVERSION;
17558 156 TheMaps[scr].screen_midi = -1;
17559 156 TheMaps[scr].csensitive = 1;
17560 156 }
17561 52 }
17562
17563
3/6
✓ Branch 0 taken 1895 times.
✓ Branch 1 taken 52 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1895 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1947 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17564 {
17565
2/2
✓ Branch 0 taken 7072 times.
✓ Branch 1 taken 52 times.
7124 for(int32_t j=0; j<MAPSCRS; j++)
17566 {
17567 7072 scr=i*MAPSCRS+j;
17568 7072 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17569
17570
2/2
✓ Branch 0 taken 905216 times.
✓ Branch 1 taken 7072 times.
912288 for(int32_t k=0; k<128; k++)
17571 {
17572 905216 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17573 905216 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17574 905216 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17575 905216 }
17576 7072 }
17577 52 }
17578 1947 }
17579 129 map_count = temp_map_count;
17580 129 clear_screen(&temp_mapscr);
17581 129 return 0;
17582 129 }
17583
17584
17585 1094437 void update_combo(newcombo& cmb, word section_version)
17586 {
17587
2/2
✓ Branch 0 taken 153720 times.
✓ Branch 1 taken 940717 times.
1094437 if(section_version < 40)
17588 {
17589
3/3
✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 14209 times.
✓ Branch 2 taken 925119 times.
940717 switch(cmb.type)
17590 {
17591 case cWATER: case cSHALLOWWATER:
17592 14209 cmb.attribytes[6] = iwRipples;
17593 14209 break;
17594 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17595 1389 cmb.attribytes[6] = iwTallGrass;
17596 1389 break;
17597 }
17598 940717 }
17599 1094437 }
17600 95 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17601 {
17602 95 reset_combo_animations();
17603 95 reset_combo_animations2();
17604
17605 95 init_combo_classes();
17606
17607 // combos
17608 95 word combos_used=0;
17609 int32_t dummy;
17610 byte padding;
17611 95 newcombo temp_combo;
17612 //word section_cversion=0;
17613
17614
2/2
✓ Branch 0 taken 6201600 times.
✓ Branch 1 taken 95 times.
6201695 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17615
1/2
✓ Branch 0 taken 6201600 times.
✗ Branch 1 not taken.
6201600 combobuf[q].clear();
17616
17617 // if(version > 0x192)
17618 // {
17619 // //section version info
17620 // if(!p_igetw(&section_version,f))
17621 // {
17622 // return qe_invalid;
17623 // }
17624
17625 // FFCore.quest_format[vCombos] = section_version;
17626
17627 // //al_trace("Combos version %d\n", section_version);
17628 // if(!p_igetw(&section_cversion,f))
17629 // {
17630 // return qe_invalid;
17631 // }
17632
17633 // //section size
17634 // if(!p_igetl(&dummy,f))
17635 // {
17636 // return qe_invalid;
17637 // }
17638 // }
17639
17640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 95 times.
95 if(version < 0x174)
17641 {
17642 combos_used=1024;
17643 }
17644
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
95 else if(version < 0x191)
17645 {
17646 4 combos_used=2048;
17647 4 }
17648 else
17649 {
17650
2/4
✓ Branch 0 taken 91 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 91 times.
✗ Branch 3 not taken.
91 if(!p_igetw(&combos_used,f))
17651 {
17652 return qe_invalid;
17653 }
17654 }
17655
17656 //finally... section data
17657
2/2
✓ Branch 0 taken 95 times.
✓ Branch 1 taken 873209 times.
873304 for(int32_t i=0; i<combos_used; i++)
17658 {
17659
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 temp_combo.clear();
17660
17661
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if ( section_version >= 11 )
17662 {
17663
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.tile,f))
17664 {
17665 return qe_invalid;
17666 }
17667 68884 }
17668 else
17669 {
17670
2/4
✓ Branch 0 taken 804325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 804325 times.
✗ Branch 3 not taken.
804325 if(!p_igetw(&temp_combo.tile,f))
17671 {
17672 return qe_invalid;
17673 }
17674 }
17675 873209 temp_combo.o_tile = temp_combo.tile;
17676
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.flip,f))
17677 {
17678 return qe_invalid;
17679 }
17680
17681
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.walk,f))
17682 {
17683 return qe_invalid;
17684 }
17685
17686
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.type,f))
17687 {
17688 return qe_invalid;
17689 }
17690
17691
2/4
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 873209 times.
✗ Branch 3 not taken.
873209 if(!p_getc(&temp_combo.csets,f))
17692 {
17693 return qe_invalid;
17694 }
17695
17696
2/2
✓ Branch 0 taken 8192 times.
✓ Branch 1 taken 865017 times.
873209 if(version < 0x193)
17697 {
17698
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17699 return qe_invalid;
17700
17701
2/4
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8192 times.
✗ Branch 3 not taken.
8192 if(!p_getc(&padding,f))
17702 return qe_invalid;
17703
17704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8192 times.
8192 if(version < 0x192)
17705 {
17706
1/2
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
8192 if(version == 0x191)
17707 {
17708 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17709 {
17710 if(!p_getc(&padding,f))
17711 return qe_invalid;
17712 }
17713 }
17714 8192 }
17715 8192 }
17716
2/2
✓ Branch 0 taken 865017 times.
✓ Branch 1 taken 8192 times.
873209 if(version >= 0x192)
17717 {
17718
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.frames,f))
17719 return qe_invalid;
17720
17721
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.speed,f))
17722 return qe_invalid;
17723
17724
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_igetw(&temp_combo.nextcombo,f))
17725 return qe_invalid;
17726
17727
2/4
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 865017 times.
✗ Branch 3 not taken.
865017 if(!p_getc(&temp_combo.nextcset,f))
17728 return qe_invalid;
17729
17730 //Base flag
17731
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=3)
17732
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.flag,f))
17733 return qe_invalid;
17734
17735
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=4)
17736 {
17737
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanim,f))
17738 return qe_invalid;
17739
17740
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_igetw(&temp_combo.nexttimer,f))
17741 return qe_invalid;
17742 399183 }
17743
17744
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=5)
17745
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.skipanimy,f))
17746 return qe_invalid;
17747
17748
2/2
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 465834 times.
865017 if(section_version>=6)
17749 {
17750
2/4
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 399183 times.
✗ Branch 3 not taken.
399183 if(!p_getc(&temp_combo.animflags,f))
17751 return qe_invalid;
17752
17753
1/2
✓ Branch 0 taken 399183 times.
✗ Branch 1 not taken.
399183 if(section_version == 6)
17754 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17755 399183 }
17756
17757
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=8) //combo Attributes[4] and userflags.
17758 {
17759
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 275536 times.
344420 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17760
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_igetl(&temp_combo.attributes[q],f))
17761 return qe_invalid;
17762
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.usrflags,f))
17763 return qe_invalid;
17764
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 if(section_version >= 20)
17765
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.genflags,f))
17766 return qe_invalid;
17767 68884 }
17768
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=10) //combo trigger flags
17769 {
17770
2/2
✓ Branch 0 taken 206652 times.
✓ Branch 1 taken 68884 times.
275536 for ( int32_t q = 0; q < 3; q++ )
17771
2/4
✓ Branch 0 taken 206652 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 206652 times.
✗ Branch 3 not taken.
206652 if(!p_igetl(&temp_combo.triggerflags[q],f))
17772 return qe_invalid;
17773 68884 }
17774
1/2
✓ Branch 0 taken 796133 times.
✗ Branch 1 not taken.
796133 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17775 {
17776 for ( int32_t q = 0; q < 2; q++ )
17777 if(!p_igetl(&temp_combo.triggerflags[q],f))
17778 return qe_invalid;
17779 }
17780
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 9)
17781
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.triggerlevel,f))
17782 return qe_invalid;
17783
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version >= 22)
17784
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.triggerbtn,f))
17785 return qe_invalid;
17786
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 24)
17787 {
17788 if(!p_getc(&temp_combo.triggeritem,f))
17789 return qe_invalid;
17790 if(!p_getc(&temp_combo.trigtimer,f))
17791 return qe_invalid;
17792 }
17793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 25)
17794 if(!p_getc(&temp_combo.trigsfx,f))
17795 return qe_invalid;
17796
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 27)
17797 if(!p_igetl(&temp_combo.trigchange,f))
17798 return qe_invalid;
17799
17800
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 29)
17801 {
17802 if(!p_igetw(&temp_combo.trigprox,f))
17803 return qe_invalid;
17804 if(!p_getc(&temp_combo.trigctr,f))
17805 return qe_invalid;
17806 if(!p_igetl(&temp_combo.trigctramnt,f))
17807 return qe_invalid;
17808 }
17809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 30)
17810 if(!p_getc(&temp_combo.triglbeam,f))
17811 return qe_invalid;
17812
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 31)
17813 {
17814 if(!p_getc(&temp_combo.trigcschange,f))
17815 return qe_invalid;
17816 if(!p_igetw(&temp_combo.spawnitem,f))
17817 return qe_invalid;
17818 if(!p_igetw(&temp_combo.spawnenemy,f))
17819 return qe_invalid;
17820 if(!p_getc(&temp_combo.exstate,f))
17821 return qe_invalid;
17822 if(!p_igetl(&temp_combo.spawnip,f))
17823 return qe_invalid;
17824 if(!p_getc(&temp_combo.trigcopycat,f))
17825 return qe_invalid;
17826 }
17827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865017 times.
865017 if(section_version >= 32)
17828 if(!p_getc(&temp_combo.trigcooldown,f))
17829 return qe_invalid;
17830
17831
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=12) //combo label
17832 {
17833 char label[12];
17834 68884 label[11] = '\0';
17835
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 757724 times.
826608 for ( int32_t q = 0; q < 11; q++ )
17836
2/4
✓ Branch 0 taken 757724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 757724 times.
✗ Branch 3 not taken.
757724 if(!p_getc(&label[q],f))
17837 return qe_invalid;
17838
1/2
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
68884 temp_combo.label = label;
17839 68884 }
17840
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=13) //attribytes[4]
17841
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 0; q < 4; q++ )
17842
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17843 68884 return qe_invalid;
17844 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17845 * This fixes a poor implementation of a ->next flag bug thing.
17846 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17847 * there was a version bump a few weeks before a change that broke stuff.
17848 */
17849
3/4
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 68884 times.
865017 if (section_version >= 13 && section_version < 21)
17850 {
17851 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17852 }
17853 //combo scripts
17854
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=14)
17855 {
17856
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetw(&temp_combo.script,f))
17857 return qe_invalid;
17858
2/2
✓ Branch 0 taken 137768 times.
✓ Branch 1 taken 68884 times.
206652 for ( int32_t q = 0; q < 2; q++ )
17859
2/4
✓ Branch 0 taken 137768 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 137768 times.
✗ Branch 3 not taken.
137768 if(!p_igetl(&temp_combo.initd[q],f))
17860 return qe_invalid;
17861 68884 }
17862 //al_trace("Read combo script data\n");
17863
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 796133 times.
865017 if(section_version>=15)
17864 {
17865
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17866
2/2
✓ Branch 0 taken 37028 times.
✓ Branch 1 taken 31856 times.
68884 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17867
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17868
2/4
✓ Branch 0 taken 68884 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68884 times.
✗ Branch 3 not taken.
68884 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17869 68884 }
17870
2/2
✓ Branch 0 taken 796133 times.
✓ Branch 1 taken 68884 times.
865017 if(section_version>=17) //attribytes[4]
17871 {
17872
2/2
✓ Branch 0 taken 275536 times.
✓ Branch 1 taken 68884 times.
344420 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17873
2/4
✓ Branch 0 taken 275536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 275536 times.
✗ Branch 3 not taken.
275536 if(!p_getc(&temp_combo.attribytes[q],f))
17874 return qe_invalid;
17875
2/2
✓ Branch 0 taken 551072 times.
✓ Branch 1 taken 68884 times.
619956 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17876
2/4
✓ Branch 0 taken 551072 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 551072 times.
✗ Branch 3 not taken.
551072 if(!p_igetw(&temp_combo.attrishorts[q],f))
17877 return qe_invalid;
17878 68884 }
17879
17880
1/2
✓ Branch 0 taken 865017 times.
✗ Branch 1 not taken.
865017 if(version < 0x193)
17881 for(int32_t q=0; q<11; q++)
17882 if(!p_getc(&dummy,f))
17883 return qe_invalid;
17884 865017 }
17885
17886 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17887
3/6
✓ Branch 0 taken 399183 times.
✓ Branch 1 taken 474026 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399183 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
873209 if((version < 0x211)||((version == 0x211)&&(build<7)))
17888 {
17889
3/4
✓ Branch 0 taken 474026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 465834 times.
✓ Branch 3 taken 8192 times.
474026 if(!get_qr(qr_NEWENEMYTILES))
17890 {
17891
1/5
✓ Branch 0 taken 8192 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
8192 switch(temp_combo.tile)
17892 {
17893 case 130:
17894 temp_combo.tile = 132;
17895 break;
17896
17897 case 131:
17898 temp_combo.tile = 133;
17899 break;
17900
17901 case 132:
17902 temp_combo.tile = 130;
17903 break;
17904
17905 case 133:
17906 temp_combo.tile = 131;
17907 break;
17908 }
17909 8192 }
17910 474026 }
17911
17912
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 15)
17913 804325 temp_combo.o_tile = temp_combo.tile;
17914
17915
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version<18) //upper bits for .walk
17916 804325 temp_combo.walk |= 0xF0;
17917
17918
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 19)
17919
2/2
✓ Branch 0 taken 3217300 times.
✓ Branch 1 taken 804325 times.
4021625 for(int32_t q = 0; q < 4; ++q)
17920 4021625 temp_combo.attributes[q] *= 10000L;
17921
17922
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 23)
17923 {
17924
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 872825 times.
873209 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17925 {
17926 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17927 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17928 case cTRIGGERGENERIC: case cCSWITCH:
17929 384 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17930 384 }
17931 873209 }
17932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 25)
17933 {
17934
2/2
✓ Branch 0 taken 3061 times.
✓ Branch 1 taken 870148 times.
873209 switch(temp_combo.type)
17935 {
17936 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3061 times.
3061 if(!(temp_combo.usrflags & cflag3))
17938 3061 temp_combo.attribytes[3] = WAV_DOOR;
17939 3061 temp_combo.usrflags &= ~cflag3;
17940 3061 break;
17941 }
17942 873209 }
17943
17944
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 26)
17945
2/2
✓ Branch 0 taken 872622 times.
✓ Branch 1 taken 587 times.
873796 if(temp_combo.type == cARMOS)
17946
1/2
✓ Branch 0 taken 587 times.
✗ Branch 1 not taken.
587 if(temp_combo.usrflags & cflag1)
17947 temp_combo.usrflags |= cflag3;
17948
17949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 27)
17950 {
17951
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17952 temp_combo.trigchange = 1;
17953
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17954 temp_combo.trigchange = -1;
17955 873209 else temp_combo.trigchange = 0;
17956 873209 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17957 873209 }
17958
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 873209 times.
873209 if(section_version < 28)
17959 {
17960
2/2
✓ Branch 0 taken 1689 times.
✓ Branch 1 taken 871520 times.
873209 switch(temp_combo.type)
17961 {
17962 case cLOCKBLOCK: case cLOCKEDCHEST:
17963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1689 times.
1689 if(temp_combo.usrflags & cflag7)
17964 temp_combo.usrflags |= cflag8;
17965 1689 else temp_combo.usrflags &= ~cflag8;
17966 1689 temp_combo.usrflags &= ~cflag7;
17967 1689 break;
17968 }
17969
2/2
✓ Branch 0 taken 69 times.
✓ Branch 1 taken 873140 times.
873209 switch(temp_combo.type)
17970 {
17971 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17972 69 temp_combo.attrishorts[2] = -1;
17973 69 temp_combo.usrflags |= cflag7;
17974 69 break;
17975 }
17976 873209 }
17977
2/2
✓ Branch 0 taken 68884 times.
✓ Branch 1 taken 804325 times.
873209 if(section_version < 20)
17978 {
17979 804325 temp_combo.genflags = 0;
17980
2/2
✓ Branch 0 taken 19291 times.
✓ Branch 1 taken 785034 times.
804325 switch(temp_combo.type)
17981 {
17982 case cPUSH_WAIT: case cPUSH_HEAVY:
17983 case cPUSH_HW: case cL_STATUE:
17984 case cR_STATUE: case cPUSH_HEAVY2:
17985 case cPUSH_HW2: case cPOUND:
17986 case cC_STATUE: case cMIRROR:
17987 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17988 case cMAGICPRISM: case cMAGICPRISM4:
17989 case cMAGICSPONGE: case cEYEBALL_A:
17990 case cEYEBALL_B: case cEYEBALL_4:
17991 case cBUSH: case cFLOWERS:
17992 case cLOCKBLOCK: case cLOCKBLOCK2:
17993 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17994 case cCHEST: case cCHEST2:
17995 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17996 case cBOSSCHEST: case cBOSSCHEST2:
17997 case cBUSHNEXT: case cBUSHTOUCHY:
17998 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17999 case cSIGNPOST: case cCSWITCHBLOCK:
18000 case cTORCH: case cTRIGGERGENERIC:
18001
1/2
✓ Branch 0 taken 19291 times.
✗ Branch 1 not taken.
19291 if(temp_combo.usrflags & cflag16)
18002 {
18003 temp_combo.genflags |= cflag1;
18004 temp_combo.usrflags &= ~cflag16;
18005 }
18006 19291 break;
18007 }
18008 804325 }
18009
18010 873209 update_combo(temp_combo, section_version);
18011
18012
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 if(i>=start_combo)
18013 {
18014
1/2
✓ Branch 0 taken 873209 times.
✗ Branch 1 not taken.
873209 combobuf[i] = temp_combo;
18015 873209 }
18016 873209 }
18017
18018
3/6
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 91 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
95 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
18019 {
18020
2/2
✓ Branch 0 taken 261120 times.
✓ Branch 1 taken 4 times.
261124 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18021 {
18022
1/2
✓ Branch 0 taken 261120 times.
✗ Branch 1 not taken.
261120 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
18023 {
18024 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
18025 }
18026 261120 }
18027 4 }
18028
18029 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
18030
4/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 83 times.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 12 times.
95 if(version == 0x210 && !is_zquest())
18031 {
18032
2/2
✓ Branch 0 taken 783360 times.
✓ Branch 1 taken 12 times.
783372 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18033
2/2
✓ Branch 0 taken 783351 times.
✓ Branch 1 taken 9 times.
783369 if(combobuf[tmpcounter].type == cLADDERONLY)
18034 9 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
18035 12 }
18036
18037
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<7)
18038 {
18039
2/2
✓ Branch 0 taken 1044480 times.
✓ Branch 1 taken 16 times.
1044496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18040 {
18041
6/9
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 174 times.
✓ Branch 2 taken 126 times.
✓ Branch 3 taken 45 times.
✓ Branch 4 taken 45 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 1043840 times.
1044480 switch(combobuf[tmpcounter].type)
18042 {
18043 case cSLASH:
18044 250 combobuf[tmpcounter].type=cSLASHTOUCHY;
18045 250 break;
18046
18047 case cSLASHITEM:
18048 174 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
18049 174 break;
18050
18051 case cBUSH:
18052 126 combobuf[tmpcounter].type=cBUSHTOUCHY;
18053 126 break;
18054
18055 case cFLOWERS:
18056 45 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
18057 45 break;
18058
18059 case cTALLGRASS:
18060 45 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
18061 45 break;
18062
18063 case cSLASHNEXT:
18064 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
18065 break;
18066
18067 case cSLASHNEXTITEM:
18068 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
18069 break;
18070
18071 case cBUSHNEXT:
18072 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
18073 break;
18074 }
18075 1044480 }
18076 16 }
18077
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 93 times.
95 if (section_version < 16)
18078 {
18079
2/2
✓ Branch 0 taken 6071040 times.
✓ Branch 1 taken 93 times.
6071133 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
18080 {
18081
2/2
✓ Branch 0 taken 6062986 times.
✓ Branch 1 taken 8054 times.
6071040 if (combobuf[tmpcounter].type == cWATER)
18082 {
18083 8054 combobuf[tmpcounter].attributes[0] = 40000L;
18084 8054 }
18085 6071040 }
18086 93 }
18087
3/4
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94 times.
✓ Branch 3 taken 1 times.
95 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18088 {
18089 1 combobuf[0].walk = 0xF0;
18090 1 combobuf[0].type = 0;
18091 1 combobuf[0].flag = 0;
18092 1 }
18093
18094 //Now for the new combo alias reset
18095
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 16 times.
95 if(section_version<2)
18096 {
18097
2/2
✓ Branch 0 taken 131072 times.
✓ Branch 1 taken 16 times.
131088 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
18098 {
18099 131072 combo_aliases[j].width = 0;
18100 131072 combo_aliases[j].height = 0;
18101 131072 combo_aliases[j].layermask = 0;
18102
18103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].combos != NULL)
18104 {
18105
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].combos;
18106 131072 }
18107
18108
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 131072 times.
131072 if(combo_aliases[j].csets != NULL)
18109 {
18110
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 delete[] combo_aliases[j].csets;
18111 131072 }
18112
18113
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].combos = new word[1];
18114
1/2
✓ Branch 0 taken 131072 times.
✗ Branch 1 not taken.
131072 combo_aliases[j].csets = new byte[1];
18115 131072 combo_aliases[j].combos[0] = 0;
18116 131072 combo_aliases[j].csets[0] = 0;
18117 131072 }
18118 16 }
18119
18120
18121
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations();
18122
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 setup_combo_animations2();
18123 95 return 0;
18124 95 }
18125 221228 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
18126 {
18127 byte combo_has_flags;
18128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221228 times.
221228 if(!p_getc(&combo_has_flags,f))
18129 return qe_invalid;
18130
18131 221228 temp_combo.clear();
18132
2/2
✓ Branch 0 taken 144925 times.
✓ Branch 1 taken 76303 times.
221228 if(combo_has_flags)
18133 {
18134
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 76300 times.
76303 if(combo_has_flags&CHAS_BASIC)
18135 {
18136
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_igetl(&temp_combo.tile,f))
18137 {
18138 return qe_invalid;
18139 }
18140 76300 temp_combo.o_tile = temp_combo.tile;
18141
18142
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flip,f))
18143 {
18144 return qe_invalid;
18145 }
18146
18147
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.walk,f))
18148 {
18149 return qe_invalid;
18150 }
18151
18152
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.type,f))
18153 {
18154 return qe_invalid;
18155 }
18156
18157
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.flag,f))
18158 {
18159 return qe_invalid;
18160 }
18161
18162
1/2
✓ Branch 0 taken 76300 times.
✗ Branch 1 not taken.
76300 if(!p_getc(&temp_combo.csets,f))
18163 {
18164 return qe_invalid;
18165 }
18166 76300 }
18167
2/2
✓ Branch 0 taken 76280 times.
✓ Branch 1 taken 23 times.
76303 if(combo_has_flags&CHAS_SCRIPT)
18168 {
18169
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 15 times.
23 if (s_version>=41)
18170 {
18171 8 p_getcstr(&temp_combo.label, f);
18172 8 }
18173 else
18174 {
18175 char label[12];
18176 15 label[11] = '\0';
18177
2/2
✓ Branch 0 taken 165 times.
✓ Branch 1 taken 15 times.
180 for ( int32_t q = 0; q < 11; q++ )
18178 {
18179
1/2
✓ Branch 0 taken 165 times.
✗ Branch 1 not taken.
165 if(!p_getc(&label[q],f))
18180 {
18181 return qe_invalid;
18182 }
18183 165 }
18184 15 temp_combo.label = label;
18185 }
18186
18187
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
18188
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 23 times.
69 for ( int32_t q = 0; q < 2; q++ )
18189 {
18190
1/2
✓ Branch 0 taken 46 times.
✗ Branch 1 not taken.
46 if(!p_igetl(&temp_combo.initd[q],f))
18191 {
18192 return qe_invalid;
18193 }
18194 46 }
18195 23 }
18196
2/2
✓ Branch 0 taken 56050 times.
✓ Branch 1 taken 20253 times.
76303 if(combo_has_flags&CHAS_ANIM)
18197 {
18198
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.frames,f))
18199 {
18200 return qe_invalid;
18201 }
18202
18203
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.speed,f))
18204 {
18205 return qe_invalid;
18206 }
18207
18208
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_igetw(&temp_combo.nextcombo,f))
18209 {
18210 return qe_invalid;
18211 }
18212
18213
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.nextcset,f))
18214 {
18215 return qe_invalid;
18216 }
18217
18218
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanim,f))
18219 {
18220 return qe_invalid;
18221 }
18222
18223
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.skipanimy,f))
18224 {
18225 return qe_invalid;
18226 }
18227
18228
1/2
✓ Branch 0 taken 20253 times.
✗ Branch 1 not taken.
20253 if(!p_getc(&temp_combo.animflags,f))
18229 {
18230 return qe_invalid;
18231 }
18232 20253 }
18233
2/2
✓ Branch 0 taken 65991 times.
✓ Branch 1 taken 10312 times.
76303 if(combo_has_flags&CHAS_ATTRIB)
18234 {
18235
2/2
✓ Branch 0 taken 41248 times.
✓ Branch 1 taken 10312 times.
51560 for ( int32_t q = 0; q < 4; q++ )
18236 {
18237
1/2
✓ Branch 0 taken 41248 times.
✗ Branch 1 not taken.
41248 if(!p_igetl(&temp_combo.attributes[q],f))
18238 {
18239 return qe_invalid;
18240 }
18241 41248 }
18242
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18243 {
18244
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_getc(&temp_combo.attribytes[q],f))
18245 {
18246 return qe_invalid;
18247 }
18248 82496 }
18249
2/2
✓ Branch 0 taken 82496 times.
✓ Branch 1 taken 10312 times.
92808 for ( int32_t q = 0; q < 8; q++ )
18250 {
18251
1/2
✓ Branch 0 taken 82496 times.
✗ Branch 1 not taken.
82496 if(!p_igetw(&temp_combo.attrishorts[q],f))
18252 {
18253 return qe_invalid;
18254 }
18255 82496 }
18256 10312 }
18257
2/2
✓ Branch 0 taken 74121 times.
✓ Branch 1 taken 2182 times.
76303 if(combo_has_flags&CHAS_FLAG)
18258 {
18259
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetl(&temp_combo.usrflags,f))
18260 {
18261 return qe_invalid;
18262 }
18263
1/2
✓ Branch 0 taken 2182 times.
✗ Branch 1 not taken.
2182 if(!p_igetw(&temp_combo.genflags,f))
18264 {
18265 return qe_invalid;
18266 }
18267 2182 }
18268
2/2
✓ Branch 0 taken 75530 times.
✓ Branch 1 taken 773 times.
76303 if(combo_has_flags&CHAS_TRIG)
18269 {
18270 773 int numtrigs = s_version < 36 ? 3 : 6;
18271
2/2
✓ Branch 0 taken 4209 times.
✓ Branch 1 taken 773 times.
4982 for ( int32_t q = 0; q < numtrigs; q++ )
18272 {
18273
1/2
✓ Branch 0 taken 4209 times.
✗ Branch 1 not taken.
4209 if(!p_igetl(&temp_combo.triggerflags[q],f))
18274 {
18275 return qe_invalid;
18276 }
18277 4209 }
18278
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.triggerlevel,f))
18279 {
18280 return qe_invalid;
18281 }
18282
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggerbtn,f))
18283 {
18284 return qe_invalid;
18285 }
18286
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triggeritem,f))
18287 {
18288 return qe_invalid;
18289 }
18290
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigtimer,f))
18291 {
18292 return qe_invalid;
18293 }
18294
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigsfx,f))
18295 {
18296 return qe_invalid;
18297 }
18298
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigchange,f))
18299 {
18300 return qe_invalid;
18301 }
18302
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.trigprox,f))
18303 {
18304 return qe_invalid;
18305 }
18306
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigctr,f))
18307 {
18308 return qe_invalid;
18309 }
18310
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.trigctramnt,f))
18311 {
18312 return qe_invalid;
18313 }
18314
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.triglbeam,f))
18315 {
18316 return qe_invalid;
18317 }
18318
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcschange,f))
18319 {
18320 return qe_invalid;
18321 }
18322
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnitem,f))
18323 {
18324 return qe_invalid;
18325 }
18326
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.spawnenemy,f))
18327 {
18328 return qe_invalid;
18329 }
18330
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.exstate,f))
18331 {
18332 return qe_invalid;
18333 }
18334
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetl(&temp_combo.spawnip,f))
18335 {
18336 return qe_invalid;
18337 }
18338
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcopycat,f))
18339 {
18340 return qe_invalid;
18341 }
18342
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.trigcooldown,f))
18343 {
18344 return qe_invalid;
18345 }
18346
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 773 times.
773 if(s_version >= 35)
18347 {
18348
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_cid,f))
18349 {
18350 return qe_invalid;
18351 }
18352
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_getc(&temp_combo.prompt_cs,f))
18353 {
18354 return qe_invalid;
18355 }
18356
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_x,f))
18357 {
18358 return qe_invalid;
18359 }
18360
1/2
✓ Branch 0 taken 773 times.
✗ Branch 1 not taken.
773 if(!p_igetw(&temp_combo.prompt_y,f))
18361 {
18362 return qe_invalid;
18363 }
18364 773 }
18365
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 36)
18366 {
18367
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_lstate,f))
18368 {
18369 return qe_invalid;
18370 }
18371
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_getc(&temp_combo.trig_gstate,f))
18372 {
18373 return qe_invalid;
18374 }
18375
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetl(&temp_combo.trig_statetime,f))
18376 {
18377 return qe_invalid;
18378 }
18379 630 }
18380
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 630 times.
773 if(s_version >= 37)
18381 {
18382
1/2
✓ Branch 0 taken 630 times.
✗ Branch 1 not taken.
630 if(!p_igetw(&temp_combo.trig_genscr,f))
18383 {
18384 return qe_invalid;
18385 }
18386 630 }
18387
2/2
✓ Branch 0 taken 217 times.
✓ Branch 1 taken 556 times.
773 if(s_version >= 38)
18388 {
18389
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_getc(&temp_combo.trig_group,f))
18390 {
18391 return qe_invalid;
18392 }
18393
1/2
✓ Branch 0 taken 556 times.
✗ Branch 1 not taken.
556 if(!p_igetw(&temp_combo.trig_group_val,f))
18394 {
18395 return qe_invalid;
18396 }
18397 556 }
18398 773 }
18399
2/2
✓ Branch 0 taken 76160 times.
✓ Branch 1 taken 143 times.
76303 if(combo_has_flags&CHAS_LIFT)
18400 {
18401
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftcmb,f))
18402 return qe_invalid;
18403
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftcs,f))
18404 return qe_invalid;
18405
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftundercmb,f))
18406 return qe_invalid;
18407
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftundercs,f))
18408 return qe_invalid;
18409
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftdmg,f))
18410 return qe_invalid;
18411
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftlvl,f))
18412 return qe_invalid;
18413
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftitm,f))
18414 return qe_invalid;
18415
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftflags,f))
18416 return qe_invalid;
18417
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftgfx,f))
18418 return qe_invalid;
18419
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsprite,f))
18420 return qe_invalid;
18421
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftsfx,f))
18422 return qe_invalid;
18423
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_igetw(&temp_combo.liftbreaksprite,f))
18424 return qe_invalid;
18425
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.liftbreaksfx,f))
18426 return qe_invalid;
18427
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(s_version >= 34)
18428 {
18429
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifthei,f))
18430 return qe_invalid;
18431
1/2
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
143 if(!p_getc(&temp_combo.lifttime,f))
18432 return qe_invalid;
18433 143 }
18434
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 136 times.
143 if(s_version >= 39)
18435 {
18436
1/2
✓ Branch 0 taken 136 times.
✗ Branch 1 not taken.
136 if(!p_getc(&temp_combo.lift_parent_item,f))
18437 return qe_invalid;
18438 136 }
18439 143 }
18440
2/2
✓ Branch 0 taken 76211 times.
✓ Branch 1 taken 92 times.
76303 if(combo_has_flags&CHAS_GENERAL)
18441 {
18442
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_mult,f))
18443 return qe_invalid;
18444
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_getc(&temp_combo.speed_div,f))
18445 return qe_invalid;
18446
1/2
✓ Branch 0 taken 92 times.
✗ Branch 1 not taken.
92 if(!p_igetzf(&temp_combo.speed_add,f))
18447 return qe_invalid;
18448
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 76 times.
92 if(s_version >= 42)
18449 {
18450
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_appear,f))
18451 return qe_invalid;
18452
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_disappear,f))
18453 return qe_invalid;
18454
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_loop,f))
18455 return qe_invalid;
18456
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_walking,f))
18457 return qe_invalid;
18458
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.sfx_standing,f))
18459 return qe_invalid;
18460
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_appear,f))
18461 return qe_invalid;
18462
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_disappear,f))
18463 return qe_invalid;
18464
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_walking,f))
18465 return qe_invalid;
18466
1/2
✓ Branch 0 taken 76 times.
✗ Branch 1 not taken.
76 if(!p_getc(&temp_combo.spr_standing,f))
18467 return qe_invalid;
18468 76 }
18469 92 }
18470 76303 }
18471 221228 update_combo(temp_combo, s_version);
18472 221228 return 0;
18473 221228 }
18474 129 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
18475 {
18476 129 word section_version=0;
18477 129 word section_cversion=0;
18478 129 word combos_used=0;
18479 int32_t dummy;
18480 byte padding;
18481 129 newcombo temp_combo;
18482
18483
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations();
18484
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 reset_combo_animations2();
18485
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 init_combo_classes();
18486
18487
2/2
✓ Branch 0 taken 8421120 times.
✓ Branch 1 taken 129 times.
8421249 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18488
1/2
✓ Branch 0 taken 8421120 times.
✗ Branch 1 not taken.
8421120 combobuf[q].clear();
18489
18490
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(version > 0x192) //Version info
18491 {
18492
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_version,f))
18493 {
18494 return qe_invalid;
18495 }
18496 125 FFCore.quest_format[vCombos] = section_version;
18497
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&section_cversion,f))
18498 {
18499 return qe_invalid;
18500 }
18501
18502 //section size
18503
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
18504 {
18505 return qe_invalid;
18506 }
18507 125 }
18508
18509
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(section_version > 32) //Cleanup time!
18510 {
18511
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&combos_used,f))
18512 {
18513 return qe_invalid;
18514 }
18515
2/2
✓ Branch 0 taken 221228 times.
✓ Branch 1 taken 34 times.
221262 for(int32_t i=0; i<combos_used; i++)
18516 {
18517
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 auto ret = readcombo_loop(f,section_version,temp_combo);
18518
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(ret) return ret;
18519
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 if(i>=start_combo)
18520
1/2
✓ Branch 0 taken 221228 times.
✗ Branch 1 not taken.
221228 combobuf[i] = temp_combo;
18521 221228 }
18522 34 }
18523 else //Call the old function for all old versions
18524 {
18525
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18526
1/2
✓ Branch 0 taken 95 times.
✗ Branch 1 not taken.
95 if(ret) return ret; //error, end read
18527 }
18528
18529
3/4
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 96 times.
✓ Branch 3 taken 33 times.
129 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18530 {
18531 33 combobuf[0].walk = 0xF0;
18532 33 combobuf[0].type = 0;
18533 33 combobuf[0].flag = 0;
18534 33 }
18535
18536
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations();
18537
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 setup_combo_animations2();
18538 129 return 0;
18539 129 }
18540
18541 113 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18542 {
18543 //these are here to bypass compiler warnings about unused arguments
18544 113 Header=Header;
18545 113 version=version;
18546 113 build=build;
18547
18548 int32_t dummy;
18549 113 word sversion=0, c_sversion;
18550
18551 //section version info
18552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&sversion,f))
18553 {
18554 return qe_invalid;
18555 }
18556
18557 113 FFCore.quest_format[vComboAliases] = sversion;
18558
18559 //al_trace("Combo aliases version %d\n", sversion);
18560
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&c_sversion,f))
18561 {
18562 return qe_invalid;
18563 }
18564
18565 //section size
18566
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy,f))
18567 {
18568 return qe_invalid;
18569 }
18570
18571 113 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18572
18573
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 77 times.
113 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18574 {
18575 77 max_num_combo_aliases = MAX250COMBOALIASES;
18576 77 }
18577
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18578 {
18579 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18580 }
18581
18582
2/2
✓ Branch 0 taken 452608 times.
✓ Branch 1 taken 113 times.
452721 for(int32_t j=0; j<max_num_combo_aliases; j++)
18583 {
18584 byte width,height,mask,tempcset;
18585 int32_t count;
18586 word tempword;
18587 byte tempbyte;
18588
18589
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_igetw(&tempword,f))
18590 {
18591 return qe_invalid;
18592 }
18593
18594 452608 combo_aliases[j].combo = tempword;
18595
18596
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&tempbyte,f))
18597 {
18598 return qe_invalid;
18599 }
18600
18601 452608 combo_aliases[j].cset = tempbyte;
18602
18603
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&width,f))
18604 {
18605 return qe_invalid;
18606 }
18607
18608
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&height,f))
18609 {
18610 return qe_invalid;
18611 }
18612
18613
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 if(!p_getc(&mask,f))
18614 {
18615 return qe_invalid;
18616 }
18617
18618 452608 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18619
18620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].combos != NULL)
18621 {
18622
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].combos;
18623 452608 }
18624
18625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 452608 times.
452608 if(combo_aliases[j].csets != NULL)
18626 {
18627
1/2
✓ Branch 0 taken 452608 times.
✗ Branch 1 not taken.
452608 delete[] combo_aliases[j].csets;
18628 452608 }
18629
18630 452608 combo_aliases[j].width = width;
18631 452608 combo_aliases[j].height = height;
18632 452608 combo_aliases[j].layermask = mask;
18633 452608 combo_aliases[j].combos = new word[count];
18634 452608 combo_aliases[j].csets = new byte[count];
18635
18636
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18637 {
18638
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_igetw(&tempword,f))
18639 {
18640 return qe_invalid;
18641 }
18642
18643 463821 combo_aliases[j].combos[k] = tempword;
18644 463821 }
18645
18646
2/2
✓ Branch 0 taken 463821 times.
✓ Branch 1 taken 452608 times.
916429 for(int32_t k=0; k<count; k++)
18647 {
18648
1/2
✓ Branch 0 taken 463821 times.
✗ Branch 1 not taken.
463821 if(!p_getc(&tempcset,f))
18649 {
18650 return qe_invalid;
18651 }
18652
18653 463821 combo_aliases[j].csets[k] = tempcset;
18654 463821 }
18655 452608 }
18656
18657 113 word num_combo_pools = 0;
18658
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 34 times.
113 if(sversion >= 4)
18659 {
18660
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 if(!p_igetw(&num_combo_pools,f))
18661 {
18662 return qe_invalid;
18663 }
18664 34 }
18665
18666
2/2
✓ Branch 0 taken 925696 times.
✓ Branch 1 taken 113 times.
925809 for(combo_pool& pool : combo_pools)
18667 {
18668 925696 pool.clear();
18669 }
18670
18671 113 combo_pool temp_cpool;
18672
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 113 times.
206 for(word cp = 0; cp < num_combo_pools; ++cp)
18673 {
18674 93 int32_t num_combos_in_pool = 0;
18675
2/4
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 93 times.
✗ Branch 3 not taken.
93 if(!p_igetl(&num_combos_in_pool,f))
18676 {
18677 return qe_invalid;
18678 }
18679
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 if(num_combos_in_pool < 1) continue; //nothing to read
18680
18681
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_cpool.clear();
18682
18683 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18684
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 403 times.
496 for(auto q = 0; q < num_combos_in_pool; ++q)
18685 {
18686
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetl(&cp_cid,f))
18687 {
18688 return qe_invalid;
18689 }
18690
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_getc(&cp_cs,f))
18691 {
18692 return qe_invalid;
18693 }
18694
2/4
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 403 times.
✗ Branch 3 not taken.
403 if(!p_igetw(&cp_quant,f))
18695 {
18696 return qe_invalid;
18697 }
18698
1/2
✓ Branch 0 taken 403 times.
✗ Branch 1 not taken.
403 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18699 403 }
18700
18701
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 combo_pools[cp] = temp_cpool;
18702 93 }
18703
18704 113 return 0;
18705 113 }
18706
18707 129 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18708 {
18709 //these are here to bypass compiler warnings about unused arguments
18710
18711 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18712 //Capitalized cause it'll save you a headache. -Deedee
18713 129 start_cset=start_cset;
18714 129 max_csets=max_csets;
18715 129 word s_version=0;
18716
18717 miscQdata temp_misc;
18718 129 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18719
18720 byte temp_colordata[48];
18721 char temp_palname[PALNAMESIZE];
18722
18723 int32_t dummy;
18724 word palcycles;
18725
18726
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18727 {
18728 //section version info
18729
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
18730 {
18731 return qe_invalid;
18732 }
18733
18734 125 FFCore.quest_format[vCSets] = s_version;
18735
18736 //al_trace("Color data version %d\n", s_version);
18737
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
18738 {
18739 return qe_invalid;
18740 }
18741
18742 //section size
18743
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
18744 {
18745 return qe_invalid;
18746 }
18747 125 }
18748
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if (s_version < 5)
18749 {
18750
3/4
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
93 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18751
18752 //finally... section data
18753 93 int32_t q = 0;
18754 93 int32_t p = -15;
18755
2/2
✓ Branch 0 taken 22320 times.
✓ Branch 1 taken 93 times.
22413 for(int32_t i=0; i<oldpdTOTAL; ++i)
18756 {
18757 22320 memset(temp_colordata, 0, 48);
18758
18759
1/2
✓ Branch 0 taken 22320 times.
✗ Branch 1 not taken.
22320 if(!pfread(temp_colordata,48,f))
18760 {
18761 return qe_invalid;
18762 }
18763
18764 22320 memcpy(&colordata[q*48], temp_colordata, 48);
18765
18766 22320 ++q;
18767
8/8
✓ Branch 0 taken 20832 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 1581 times.
✓ Branch 3 taken 19251 times.
✓ Branch 4 taken 186 times.
✓ Branch 5 taken 1395 times.
✓ Branch 6 taken 8 times.
✓ Branch 7 taken 178 times.
22320 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18768 {
18769
1/2
✓ Branch 0 taken 1573 times.
✗ Branch 1 not taken.
1573 if (s_version < 5) //Bumping up the size of level palettes
18770 {
18771 1573 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18772 1573 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18773 1573 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18774 1573 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18775 1573 q+=4;
18776 1573 }
18777 else
18778 {
18779 for(int m = 0; m < 4; ++m)
18780 {
18781 memset(temp_colordata, 0, 48);
18782 if(!pfread(temp_colordata,48,f))
18783 {
18784 return qe_invalid;
18785 }
18786 memcpy(&colordata[q*48], temp_colordata, 48);
18787 ++q;
18788 }
18789 }
18790 1573 }
18791 22320 ++p;
18792 22320 }
18793
18794
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 89 times.
93 if(RealOldVerion)
18795 {
18796 4 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18797 4 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18798 4 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18799 4 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18800 4 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18801 4 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18802 4 }
18803 else
18804 {
18805 89 memset(temp_colordata, 0, 48);
18806
18807
2/2
✓ Branch 0 taken 278837 times.
✓ Branch 1 taken 89 times.
278926 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18808 {
18809
1/2
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
278837 if(!pfread(temp_colordata,48,f))
18810 {
18811 return qe_invalid;
18812 }
18813
18814 278837 memcpy(&colordata[q*48], temp_colordata, 48);
18815
18816 278837 ++q;
18817
7/8
✓ Branch 0 taken 278837 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 21449 times.
✓ Branch 3 taken 257388 times.
✓ Branch 4 taken 178 times.
✓ Branch 5 taken 21271 times.
✓ Branch 6 taken 154 times.
✓ Branch 7 taken 24 times.
278837 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18818 {
18819
1/2
✓ Branch 0 taken 21425 times.
✗ Branch 1 not taken.
21425 if (s_version < 5) //Bumping up the size of level palettes
18820 {
18821 21425 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18822 21425 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18823 21425 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18824 21425 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18825 21425 q+=4;
18826 21425 }
18827 else
18828 {
18829 for(int m = 0; m < 4; ++m)
18830 {
18831 memset(temp_colordata, 0, 48);
18832 if(!pfread(temp_colordata,48,f))
18833 {
18834 return qe_invalid;
18835 }
18836 memcpy(&colordata[q*48], temp_colordata, 48);
18837 ++q;
18838 }
18839 }
18840 21425 }
18841 278837 ++p;
18842 278837 }
18843
18844
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 77 times.
89 if(s_version < 4)
18845 {
18846 12 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18847 12 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18848 12 }
18849 else
18850 {
18851
2/2
✓ Branch 0 taken 256256 times.
✓ Branch 1 taken 77 times.
256333 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18852 {
18853
1/2
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
256256 if(!pfread(temp_colordata,48,f))
18854 {
18855 return qe_invalid;
18856 }
18857
18858 256256 memcpy(&colordata[q*48], temp_colordata, 48);
18859 256256 ++q;
18860
5/6
✓ Branch 0 taken 256256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19712 times.
✓ Branch 3 taken 236544 times.
✓ Branch 4 taken 154 times.
✓ Branch 5 taken 19558 times.
256256 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18861 {
18862
1/2
✓ Branch 0 taken 19558 times.
✗ Branch 1 not taken.
19558 if (s_version < 5) //Bumping up the size of level palettes
18863 {
18864 19558 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18865 19558 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18866 19558 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18867 19558 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18868 19558 q+=4;
18869 19558 }
18870 else
18871 {
18872 for(int m = 0; m < 4; ++m)
18873 {
18874 memset(temp_colordata, 0, 48);
18875 if(!pfread(temp_colordata,48,f))
18876 {
18877 return qe_invalid;
18878 }
18879 memcpy(&colordata[q*48], temp_colordata, 48);
18880 ++q;
18881 }
18882 }
18883 19558 }
18884 256256 ++p;
18885 256256 }
18886
18887 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18888 }
18889 }
18890 93 }
18891 else
18892 {
18893
2/2
✓ Branch 0 taken 314964 times.
✓ Branch 1 taken 36 times.
315000 for(int32_t i=0; i<pdTOTAL255; ++i)
18894 {
18895 314964 memset(temp_colordata, 0, 48);
18896
18897
1/2
✓ Branch 0 taken 314964 times.
✗ Branch 1 not taken.
314964 if(!pfread(temp_colordata,48,f))
18898 {
18899 return qe_invalid;
18900 }
18901
18902 314964 memcpy(&colordata[i*48], temp_colordata, 48);
18903 314964 }
18904 }
18905
18906
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)||((version == 0x192)&&(build<76)))
18907 {
18908 4 init_palnames();
18909 4 }
18910 else
18911 {
18912 125 int32_t palnamestoread = 0;
18913
18914
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 3)
18915 12 palnamestoread = OLDMAXLEVELS;
18916 else
18917 113 palnamestoread = 512;
18918
18919
2/2
✓ Branch 0 taken 60928 times.
✓ Branch 1 taken 125 times.
61053 for(int32_t i=0; i<palnamestoread; ++i)
18920 {
18921 60928 memset(temp_palname, 0, PALNAMESIZE);
18922
18923
1/2
✓ Branch 0 taken 60928 times.
✗ Branch 1 not taken.
60928 if(!pfread(temp_palname,PALNAMESIZE,f))
18924 {
18925 return qe_invalid;
18926 }
18927
18928 60928 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18929 60928 }
18930
18931
2/2
✓ Branch 0 taken 3072 times.
✓ Branch 1 taken 125 times.
3197 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18932 {
18933 3072 memset(palnames[i], 0, PALNAMESIZE);
18934 3072 }
18935 }
18936
18937
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
18938 {
18939
2/2
✓ Branch 0 taken 32000 times.
✓ Branch 1 taken 125 times.
32125 for(int32_t i=0; i<256; i++)
18940 {
18941
2/2
✓ Branch 0 taken 96000 times.
✓ Branch 1 taken 32000 times.
128000 for(int32_t j=0; j<3; j++)
18942 {
18943 96000 temp_misc.cycles[i][j].first=0;
18944 96000 temp_misc.cycles[i][j].count=0;
18945 96000 temp_misc.cycles[i][j].speed=0;
18946 96000 }
18947 32000 }
18948
18949
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&palcycles,f))
18950 {
18951 return qe_invalid;
18952 }
18953
18954
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if (!(palcycles >= 0 && palcycles <= NUM_PAL_CYCLES))
18955 {
18956 return qe_invalid;
18957 }
18958
18959
2/2
✓ Branch 0 taken 3576 times.
✓ Branch 1 taken 125 times.
3701 for(int32_t i=0; i<palcycles; i++)
18960 {
18961
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18962 {
18963
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18964 {
18965 return qe_invalid;
18966 }
18967 10728 }
18968
18969
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18970 {
18971
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18972 {
18973 return qe_invalid;
18974 }
18975 10728 }
18976
18977
2/2
✓ Branch 0 taken 10728 times.
✓ Branch 1 taken 3576 times.
14304 for(int32_t j=0; j<3; j++)
18978 {
18979
1/2
✓ Branch 0 taken 10728 times.
✗ Branch 1 not taken.
10728 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18980 {
18981 return qe_invalid;
18982 }
18983 10728 }
18984 3576 }
18985
18986 125 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18987 125 }
18988
18989 129 return 0;
18990 129 }
18991
18992 129 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18993 {
18994 129 int32_t tiles_used=0;
18995 129 word section_version = 0;
18996 129 word section_cversion = 0;
18997 129 int32_t section_size= 0;
18998 129 byte *temp_tile = new byte[tilesize(tf32Bit)];
18999
19000 //Tile Expansion
19001 //if ( version >= 0x254 && build >= 41 )
19002
3/4
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 93 times.
129 if (version < 0x254 && build < 41)
19003 {
19004 //al_trace("Build was < 41 when reading tiles\n");
19005 93 max_tiles = ZC250MAXTILES;
19006 93 }
19007
19008 //al_trace("Max Tiles: %d\n", max_tiles);
19009
19010
2/6
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 129 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
19011 {
19012 if(!init_tiles(true, Header))
19013 {
19014 al_trace("Unable to initialize tiles\n");
19015 }
19016
19017 delete[] temp_tile;
19018 temp_tile=NULL;
19019 return 0;
19020 }
19021 else
19022 {
19023
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(version > 0x192)
19024 {
19025 //section version info
19026
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19027 {
19028 delete[] temp_tile;
19029 return qe_invalid;
19030 }
19031
19032 125 FFCore.quest_format[vTiles] = section_version;
19033
19034
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_cversion,f))
19035 {
19036 delete[] temp_tile;
19037 return qe_invalid;
19038 }
19039
19040 //section size
19041
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&section_size,f))
19042 {
19043 delete[] temp_tile;
19044 return qe_invalid;
19045 }
19046 125 }
19047
19048 //if ( build < 41 )
19049 //{
19050 // tiles_used = ZC250MAXTILES;
19051 //}
19052
19053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(version < 0x174)
19054 {
19055 tiles_used=TILES_PER_PAGE*4;
19056 } //no expanded tile space
19057
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 else if(version < 0x191)
19058 {
19059 4 tiles_used=OLDMAXTILES;
19060 4 }
19061 else
19062 {
19063 //finally... section data
19064
3/4
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
125 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
19065 {
19066
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 if(!p_igetl(&tiles_used,f))
19067 {
19068 delete[] temp_tile;
19069 return qe_invalid;
19070 }
19071 36 }
19072 else
19073 {
19074
1/2
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
89 if(!p_igetw(&tiles_used,f))
19075 {
19076 delete[] temp_tile;
19077 return qe_invalid;
19078 }
19079 }
19080 }
19081
19082
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 tiles_used=zc_min(tiles_used, max_tiles);
19083
19084 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
19085 //if ( version < 0x254 && build < 41 )
19086
3/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 36 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if ( version < 0x254 || (version == 0x254 && build < 41) )
19087 //if ( build < 41 )
19088 {
19089
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
19090 93 }
19091 else //2.55
19092 {
19093
1/2
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
36 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
19094 }
19095
19096 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
19097
19098 //al_trace("tiles_used = %d\n", tiles_used);
19099
19100
2/2
✓ Branch 0 taken 3496770 times.
✓ Branch 1 taken 129 times.
3496899 for(int32_t i=0; i<tiles_used; ++i)
19101 {
19102 3496770 byte format=tf4Bit;
19103 3496770 memset(temp_tile, 0, tilesize(tf32Bit));
19104
19105
3/6
✓ Branch 0 taken 630780 times.
✓ Branch 1 taken 2865990 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 630780 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3496770 if((version>0x211)||((version==0x211)&&(build>4)))
19106 {
19107
1/2
✓ Branch 0 taken 2865990 times.
✗ Branch 1 not taken.
2865990 if(!p_getc(&format,f))
19108 {
19109 delete[] temp_tile;
19110 return qe_invalid;
19111 }
19112 2865990 }
19113
4/4
✓ Branch 0 taken 1316436 times.
✓ Branch 1 taken 2180334 times.
✓ Branch 2 taken 612691 times.
✓ Branch 3 taken 703745 times.
3496770 if(section_version > 2 && !format)
19114 {
19115 703745 reset_tile(buf,start_tile+i,tf4Bit);
19116 703745 continue;
19117 }
19118
19119
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(!pfread(temp_tile,tilesize(format),f))
19120 {
19121 delete[] temp_tile;
19122 return qe_invalid;
19123 }
19124
19125 2793025 buf[start_tile+i].format=format;
19126
19127
1/2
✓ Branch 0 taken 2793025 times.
✗ Branch 1 not taken.
2793025 if(buf[start_tile+i].data)
19128 {
19129 2793025 free(buf[start_tile+i].data);
19130 2793025 buf[start_tile+i].data=NULL;
19131 2793025 }
19132
19133 2793025 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
19134 2793025 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
19135 2793025 }
19136 }
19137
19138
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
19139 {
19140 //al_trace("Writing blank tile data to new tiles for build < 41\n");
19141
2/2
✓ Branch 0 taken 13855140 times.
✓ Branch 1 taken 93 times.
13855233 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
19142 {
19143
19144 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
19145 13855140 reset_tile(buf,q,tf4Bit);
19146
19147
19148 /*
19149
19150 byte tempbyte;
19151 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19152 {
19153 tempbyte=buf[ZC250MAXTILES-1].data[i];
19154 buf[q].data[i] = tempbyte;
19155 }
19156 //int32_t temp = tempbyte=buf[130].data[i];
19157 //buf[q].data = buf[ZC250MAXTILES-1].data;
19158 */
19159 //reset_tile(buf,q,tf4Bit);
19160 13855140 }
19161
19162 93 }
19163
19164
4/6
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 36 times.
129 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
19165 {
19166
2/2
✓ Branch 0 taken 4121646 times.
✓ Branch 1 taken 93 times.
4121739 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19167 {
19168 //al_trace("Resetting tiles for ZC250MAXTILES, iteration: %d\n", i);
19169 4121646 reset_tile(buf,i,tf4Bit);
19170 4121646 }
19171 93 }
19172 else
19173 {
19174
2/2
✓ Branch 0 taken 6196944 times.
✓ Branch 1 taken 36 times.
6196980 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
19175 {
19176 //al_trace("Resetting tiles for build 41+\n");
19177 6196944 reset_tile(buf,i,tf4Bit);
19178 6196944 }
19179 }
19180
19181
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
19182 {
19183
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(get_qr(qr_BSZELDA)) //
19184 {
19185 byte tempbyte;
19186 int32_t floattile=wpnsbuf[iwSwim].tile;
19187
19188 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
19189 {
19190 tempbyte=buf[23].data[i];
19191 buf[23].data[i]=buf[24].data[i];
19192 buf[24].data[i]=buf[25].data[i];
19193 buf[25].data[i]=buf[26].data[i];
19194 buf[26].data[i]=tempbyte;
19195 }
19196 //swim tiles are out of order, too, but nobody cared? -Z
19197 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19198 {
19199 tempbyte=buf[floattile+11].data[i];
19200 buf[floattile+11].data[i]=buf[floattile+12].data[i];
19201 buf[floattile+12].data[i]=tempbyte;
19202 }
19203 }
19204 4 }
19205
19206
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
19207 {
19208
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 4 times.
16 if(!get_qr(qr_NEWENEMYTILES))
19209 {
19210 byte tempbyte;
19211
19212
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 4 times.
516 for(int32_t i=0; i<tilesize(tf4Bit); i++)
19213 {
19214 512 tempbyte=buf[130].data[i];
19215 512 buf[130].data[i]=buf[132].data[i];
19216 512 buf[132].data[i]=tempbyte;
19217
19218 512 tempbyte=buf[131].data[i];
19219 512 buf[131].data[i]=buf[133].data[i];
19220 512 buf[133].data[i]=tempbyte;
19221 512 }
19222 4 }
19223 16 }
19224
19225 129 al_trace("Registering blank tiles\n");
19226 129 register_blank_tiles();
19227
19228 //memset(temp_tile, 0, tilesize(tf32Bit));
19229
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 delete[] temp_tile;
19230 129 temp_tile=NULL;
19231 129 return 0;
19232 129 }
19233
19234 129 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
19235 {
19236 129 byte *mf=midi_flags;
19237 int32_t dummy;
19238 word dummy2;
19239 // zcmidi_ temp_midi;
19240 int32_t tunes_to_read;
19241 129 int32_t tune_count=0;
19242 129 word section_version=0;
19243 129 zctune temp;
19244
19245
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version < 0x193)
19246 {
19247 // mf=Header->data_flags+ZQ_MIDIS2;
19248
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
4 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
19249 {
19250 4 tunes_to_read=MAXCUSTOMMIDIS192b177;
19251 4 }
19252 else
19253 {
19254 tunes_to_read=MAXCUSTOMTUNES;
19255 }
19256 4 }
19257 else
19258 {
19259 //section version info
19260
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&section_version,f))
19261 {
19262 return qe_invalid;
19263 }
19264
19265 125 FFCore.quest_format[vMIDIs] = section_version;
19266
19267 //al_trace("Tunes version %d\n", section_version);
19268
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy2,f))
19269 {
19270 return qe_invalid;
19271 }
19272
19273 //section size
19274
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19275 {
19276 return qe_invalid;
19277 }
19278
19279 //finally... section data
19280
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!pfread(midi_flags,sizeof(midi_flags),f))
19281 {
19282 return qe_invalid;
19283 }
19284
19285 125 tunes_to_read=MAXCUSTOMTUNES;
19286 }
19287
19288
2/2
✓ Branch 0 taken 32508 times.
✓ Branch 1 taken 129 times.
32637 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
19289 {
19290
2/2
✓ Branch 0 taken 30206 times.
✓ Branch 1 taken 2302 times.
32508 if(get_bit(mf, i))
19291 {
19292 2302 ++tune_count;
19293 2302 }
19294 32508 }
19295
19296 129 reset_tunes(tunes); //reset_midis(midis);
19297
19298
2/2
✓ Branch 0 taken 31628 times.
✓ Branch 1 taken 129 times.
31757 for(int32_t i=0; i<tunes_to_read; i++)
19299 {
19300 31628 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
19301
19302 31628 tunes[i].reset(); // reset_midi(midis+i);
19303
19304
2/2
✓ Branch 0 taken 29326 times.
✓ Branch 1 taken 2302 times.
31628 if(get_bit(mf,i))
19305 {
19306
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 4)
19307 {
19308
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if(!pfread(&temp.title,sizeof(char)*20,f))
19309 {
19310 return qe_invalid;
19311 }
19312 717 }
19313 else
19314 {
19315
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.title,sizeof(temp.title),f))
19316 {
19317 return qe_invalid;
19318 }
19319 }
19320
19321
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.start,f))
19322 {
19323 return qe_invalid;
19324 }
19325
19326
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_start,f))
19327 {
19328 return qe_invalid;
19329 }
19330
19331
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetl(&temp.loop_end,f))
19332 {
19333 return qe_invalid;
19334 }
19335
19336
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.loop,f))
19337 {
19338 return qe_invalid;
19339 }
19340
19341
1/2
✓ Branch 0 taken 2302 times.
✗ Branch 1 not taken.
2302 if(!p_igetw(&temp.volume,f))
19342 {
19343 return qe_invalid;
19344 }
19345
19346
2/2
✓ Branch 0 taken 2224 times.
✓ Branch 1 taken 78 times.
2302 if(Header->zelda_version < 0x193)
19347 {
19348
1/2
✓ Branch 0 taken 78 times.
✗ Branch 1 not taken.
78 if(!p_igetl(&dummy,f))
19349 {
19350 return qe_invalid;
19351 }
19352 78 }
19353
19354
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version >= 3)
19355 {
19356
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19357 {
19358 return qe_invalid;
19359 }
19360 1585 }
19361
19362 2302 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19363
19364
2/2
✓ Branch 0 taken 717 times.
✓ Branch 1 taken 1585 times.
2302 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19365 {
19366 // old format - a midi is a midi
19367
1/2
✓ Branch 0 taken 717 times.
✗ Branch 1 not taken.
717 if((tunes[i].data=read_midi(f))==NULL)
19368 {
19369 return qe_invalid;
19370 }
19371
19372 //yes you can do this. Isn't the ? operator awesome? :)
19373 717 tunes[i].format = MFORMAT_MIDI;
19374 717 }
19375 else
19376 {
19377 // 'midi' could be midi or nes, gb, ... music
19378
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19379 {
19380 return qe_invalid;
19381 }
19382
19383 1585 zctune *ptr = &tunes[i];
19384
19385
1/2
✓ Branch 0 taken 1585 times.
✗ Branch 1 not taken.
1585 switch(temp.format)
19386 {
19387 case MFORMAT_MIDI:
19388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1585 times.
1585 if((ptr->data=read_midi(f))==NULL)
19389 {
19390 return qe_invalid;
19391 }
19392
19393 1585 break;
19394
19395 default:
19396 return qe_invalid;
19397 break;
19398 }
19399 }
19400 2302 }
19401 31628 }
19402
19403 129 return 0;
19404 129 }
19405
19406 129 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19407 {
19408 int32_t dummy;
19409 ZCHEATS tempzcheats;
19410 129 char temp_use_cheats=1;
19411 129 memset(&tempzcheats, 0, sizeof(tempzcheats));
19412 129 word s_version = 0;
19413
19414
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
129 if(Header->zelda_version > 0x192)
19415 {
19416 //section version info
19417
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&s_version,f))
19418 {
19419 return qe_invalid;
19420 }
19421
19422 125 FFCore.quest_format[vCheats] = s_version;
19423 //al_trace("Cheats version %d\n", dummy);
19424
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetw(&dummy,f))
19425 {
19426 return qe_invalid;
19427 }
19428
19429 //section size
19430
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_igetl(&dummy,f))
19431 {
19432 return qe_invalid;
19433 }
19434
19435 //finally... section data
19436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(!p_getc(&temp_use_cheats,f))
19437 {
19438 return qe_invalid;
19439 }
19440 125 }
19441
19442
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(Header->data_flags[ZQ_CHEATS2])
19443 {
19444
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!p_igetl(&tempzcheats.flags,f))
19445 {
19446 return qe_invalid;
19447 }
19448
19449
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19450 {
19451 return qe_invalid;
19452 }
19453 129 }
19454
19455 129 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19456 129 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19457
19458 129 return 0;
19459 129 }
19460
19461 307 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
19462 {
19463 int32_t dummy;
19464 307 word s_version=0, s_cversion=0;
19465 byte padding;
19466
19467 307 zinitdata temp_zinit;
19468
19469 // Legacy item properties (now integrated into itemdata)
19470 byte sword_hearts[4];
19471 byte beam_hearts[4];
19472 307 byte beam_percent=0;
19473 word beam_power[4];
19474 307 byte hookshot_length=99;
19475 307 byte hookshot_links=100;
19476 307 byte longshot_length=99;
19477 307 byte longshot_links=100;
19478 307 byte moving_fairy_hearts=3;
19479 307 byte moving_fairy_heart_percent=0;
19480 307 byte stationary_fairy_hearts=3;
19481 307 byte stationary_fairy_heart_percent=0;
19482 307 byte moving_fairy_magic=0;
19483 307 byte moving_fairy_magic_percent=0;
19484 307 byte stationary_fairy_magic=0;
19485 307 byte stationary_fairy_magic_percent=0;
19486 307 byte blue_potion_hearts=100;
19487 307 byte blue_potion_heart_percent=1;
19488 307 byte red_potion_hearts=100;
19489 307 byte red_potion_heart_percent=1;
19490 307 byte blue_potion_magic=100;
19491 307 byte blue_potion_magic_percent=1;
19492 307 byte red_potion_magic=100;
19493 307 byte red_potion_magic_percent=1;
19494
19495
2/2
✓ Branch 0 taken 129 times.
✓ Branch 1 taken 178 times.
307 temp_zinit.subscreen_style=get_qr(qr_COOLSCROLL)?1:0;
19496
19497
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(Header->zelda_version > 0x192)
19498 {
19499 //section version info
19500
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_version,f))
19501 {
19502 return qe_invalid;
19503 }
19504
19505 125 FFCore.quest_format[vInitData] = s_version;
19506
19507 //al_trace("Init data version %d\n", s_version);
19508
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&s_cversion,f))
19509 {
19510 return qe_invalid;
19511 }
19512
19513 //section size
19514
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetl(&dummy,f))
19515 {
19516 return qe_invalid;
19517 }
19518 125 }
19519
19520 /* HIGHLY UNORTHODOX UPDATING THING, by L
19521 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19522 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19523 * changing from 13 to 14.
19524 */
19525
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 14)
19526 16 fixpolsvoice=true;
19527
19528 /* End highly unorthodox updating thing */
19529
19530
5/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 75 times.
✓ Branch 5 taken 38 times.
129 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19531 38 temp_zinit.jump_hero_layer_threshold=0;
19532
19533
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
129 if(s_version >= 10)
19534 {
19535 char temp;
19536
19537 //new-style items
19538
2/2
✓ Branch 0 taken 28928 times.
✓ Branch 1 taken 113 times.
29041 for(int32_t j=0; j<256; j++)
19539 {
19540
2/4
✓ Branch 0 taken 28928 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 28928 times.
28928 if(!p_getc(&temp,f))
19541 return qe_invalid;
19542
19543 28928 temp_zinit.items[j] = (temp != 0);
19544 28928 }
19545 113 }
19546
19547
5/6
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 53 times.
✓ Branch 5 taken 53 times.
129 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19548 {
19549 char temp;
19550
19551 //finally... section data
19552
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 53 times.
✓ Branch 3 taken 53 times.
178 if((Header->zelda_version > 0x192)||
19553 //new only
19554 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19555 {
19556 //OLD-style items... sigh
19557
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 10)
19558 {
19559
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19560 {
19561 return qe_invalid;
19562 }
19563
19564 12 temp_zinit.items[iRaft]=(temp != 0);
19565
19566
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19567 {
19568 return qe_invalid;
19569 }
19570
19571 12 temp_zinit.items[iLadder]=(temp != 0);
19572
19573
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19574 {
19575 return qe_invalid;
19576 }
19577
19578 12 temp_zinit.items[iBook]=(temp != 0);
19579
19580
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19581 {
19582 return qe_invalid;
19583 }
19584
19585 12 temp_zinit.items[iMKey]=(temp!=0);
19586
19587
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19588 {
19589 return qe_invalid;
19590 }
19591
19592 12 temp_zinit.items[iFlippers]=(temp != 0);
19593
19594
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19595 {
19596 return qe_invalid;
19597 }
19598
19599 12 temp_zinit.items[iBoots]=(temp!=0);
19600 12 }
19601 125 }
19602
19603
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 166 times.
178 if(s_version < 10)
19604 {
19605 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19606
19607
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempring,f))
19608 {
19609 return qe_invalid;
19610 }
19611
19612
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempsword,f))
19613 {
19614 return qe_invalid;
19615 }
19616
19617
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempshield,f))
19618 {
19619 return qe_invalid;
19620 }
19621
19622
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwallet,f))
19623 {
19624 return qe_invalid;
19625 }
19626
19627
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbracelet,f))
19628 {
19629 return qe_invalid;
19630 }
19631
19632
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempamulet,f))
19633 {
19634 return qe_invalid;
19635 }
19636
19637
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbow,f))
19638 {
19639 return qe_invalid;
19640 }
19641
19642 //old only
19643
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19644 {
19645 tempring=(tempring)?(1<<(tempring-1)):0;
19646 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19647 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19648 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19649 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19650 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19651 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19652 }
19653
19654 //rings start at level 2... wtf
19655 //account for this -DD
19656 12 tempring <<= 1;
19657
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19658
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19659
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19660
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19661 //bracelet ALSO starts at level 2 :-( -DD
19662 12 tempbracelet<<=1;
19663
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19664
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19665
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19666
19667 //new only
19668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build>173))
19669 {
19670 for(int32_t q=0; q<32; q++)
19671 {
19672 if(!p_getc(&padding,f))
19673 {
19674 return qe_invalid;
19675 }
19676 }
19677 }
19678
19679 char tempcandle, tempboomerang, temparrow, tempwhistle;
19680
19681
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempcandle,f))
19682 {
19683 return qe_invalid;
19684 }
19685
19686
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempboomerang,f))
19687 {
19688 return qe_invalid;
19689 }
19690
19691
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temparrow,f))
19692 {
19693 return qe_invalid;
19694 }
19695
19696
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19697 {
19698 return qe_invalid;
19699 }
19700
19701
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19702
19703
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempwhistle,f))
19704 {
19705 return qe_invalid;
19706 }
19707
19708 //old only
19709
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version == 0x192)&&(Header->build<174))
19710 {
19711 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19712 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19713 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19714 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19715 }
19716
19717
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19718
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19719
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19720
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19721 //What about the potion...?
19722
19723 12 }
19724
19725
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 89 times.
178 if(s_version < 29)
19726 {
19727 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19728 //to jab out my eye...
19729
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19730 return qe_invalid;
19731 89 temp_zinit.bombs = padding;
19732
19733
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19734 return qe_invalid;
19735 89 temp_zinit.super_bombs = padding;
19736 89 }
19737
19738 //Back to more OLD item code
19739
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 12 times.
178 if(s_version < 10)
19740 {
19741
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
12 if((Header->zelda_version > 0x192)||
19742 //new only
19743 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19744 {
19745
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19746 {
19747 return qe_invalid;
19748 }
19749
19750
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19751
19752
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19753 {
19754 return qe_invalid;
19755 }
19756
19757
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19758
19759
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19760 {
19761 return qe_invalid;
19762 }
19763
19764
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19765
19766
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19772
19773
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19774 {
19775 return qe_invalid;
19776 }
19777
19778
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19779
19780
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19781 {
19782 return qe_invalid;
19783 }
19784
19785
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19786
19787
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19788 {
19789 return qe_invalid;
19790 }
19791
19792
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19793
19794
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19795 {
19796 return qe_invalid;
19797 }
19798
19799
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19800
19801
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19802 {
19803 return qe_invalid;
19804 }
19805
19806
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19807
19808
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temp,f))
19809 {
19810 return qe_invalid;
19811 }
19812
19813
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 if(Header->zelda_version == 0x192)
19814 {
19815 for(int32_t q=0; q<32; q++)
19816 {
19817 if(!p_getc(&padding,f))
19818 {
19819 return qe_invalid;
19820 }
19821 }
19822 }
19823 12 }
19824 12 }
19825
19826 //old only
19827
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
24 if((Header->zelda_version == 0x192)&&(Header->build<174))
19828 {
19829 byte equipment, items; //bit flags
19830
19831 if(!p_getc(&equipment,f))
19832 {
19833 return qe_invalid;
19834 }
19835
19836 temp_zinit.items[iRaft]=(get_bit(&equipment, idE_RAFT)!=0);
19837 temp_zinit.items[iLadder]=(get_bit(&equipment, idE_LADDER)!=0);
19838 temp_zinit.items[iBook]=(get_bit(&equipment, idE_BOOK)!=0);
19839 temp_zinit.items[iMKey]=(get_bit(&equipment, idE_KEY)!=0);
19840 temp_zinit.items[iFlippers]=(get_bit(&equipment, idE_FLIPPERS)!=0);
19841 temp_zinit.items[iBoots]=(get_bit(&equipment, idE_BOOTS)!=0);
19842
19843
19844 if(!p_getc(&items,f))
19845 {
19846 return qe_invalid;
19847 }
19848
19849 temp_zinit.items[iWand]=(get_bit(&items, idI_WAND)!=0);
19850 temp_zinit.items[iLetter]=(get_bit(&items, idI_LETTER)!=0);
19851 temp_zinit.items[iLens]=(get_bit(&items, idI_LENS)!=0);
19852 temp_zinit.items[iHookshot]=(get_bit(&items, idI_HOOKSHOT)!=0);
19853 temp_zinit.items[iBait]=(get_bit(&items, idI_BAIT)!=0);
19854 temp_zinit.items[iHammer]=(get_bit(&items, idI_HAMMER)!=0);
19855 }
19856
19857 if(!p_getc(&temp_zinit.hc,f))
19858 {
19859 return qe_invalid;
19860 }
19861
19862
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
19863 {
19864 byte temphp;
19865
19866
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19867 {
19868 return qe_invalid;
19869 }
19870
19871 12 temp_zinit.start_heart=temphp;
19872
19873
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&temphp,f))
19874 {
19875 return qe_invalid;
19876 }
19877
19878 12 temp_zinit.cont_heart=temphp;
19879 12 }
19880 else
19881 {
19882
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_heart,f))
19883 {
19884 return qe_invalid;
19885 }
19886
19887
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.cont_heart,f))
19888 {
19889 return qe_invalid;
19890 }
19891 }
19892
19893
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.hcp,f))
19894 {
19895 return qe_invalid;
19896 }
19897
19898
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version >= 14)
19899 {
19900
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19901 {
19902 return qe_invalid;
19903 }
19904
19905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version<16) // July 2007
19906 {
19907 if(get_qr(qr_BRANGPICKUP+1))
19908 temp_zinit.hcp_per_hc = 0xFF;
19909
19910 //Dispose of legacy rule
19911 set_qr(qr_BRANGPICKUP+1, 0);
19912 }
19913 113 }
19914
19915
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 36 times.
125 if(s_version < 29)
19916 {
19917
2/4
✓ Branch 0 taken 89 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 89 times.
✗ Branch 3 not taken.
89 if(!p_getc(&padding,f))
19918 return qe_invalid;
19919 89 temp_zinit.max_bombs = padding;
19920 89 }
19921
19922
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.keys,f))
19923 {
19924 return qe_invalid;
19925 }
19926
19927
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_igetw(&temp_zinit.rupies,f))
19928 {
19929 return qe_invalid;
19930 }
19931
19932
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.triforce,f))
19933 {
19934 return qe_invalid;
19935 }
19936
19937
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19938 {
19939
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19940 {
19941
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.map[i],f))
19942 {
19943 return qe_invalid;
19944 }
19945 7232 }
19946
19947
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19948 {
19949
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.compass[i],f))
19950 {
19951 return qe_invalid;
19952 }
19953 7232 }
19954 113 }
19955 else
19956 {
19957
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19958 {
19959
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.map[i],f))
19960 {
19961 return qe_invalid;
19962 }
19963 384 }
19964
19965
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19966 {
19967
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 384 times.
384 if(!p_getc(&temp_zinit.compass[i],f))
19968 {
19969 return qe_invalid;
19970 }
19971 384 }
19972 }
19973
19974
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version > 0x192)||
19975 //new only
19976 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19977 {
19978
3/6
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19979 {
19980
2/2
✓ Branch 0 taken 7232 times.
✓ Branch 1 taken 113 times.
7345 for(int32_t i=0; i<64; i++)
19981 {
19982
2/4
✓ Branch 0 taken 7232 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7232 times.
7232 if(!p_getc(&temp_zinit.boss_key[i],f))
19983 {
19984 return qe_invalid;
19985 }
19986 7232 }
19987 113 }
19988 else
19989 {
19990
2/2
✓ Branch 0 taken 384 times.
✓ Branch 1 taken 12 times.
396 for(int32_t i=0; i<32; i++)
19991 {
19992
2/4
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 384 times.
✗ Branch 3 not taken.
384 if(!p_getc(&temp_zinit.boss_key[i],f))
19993 {
19994 return qe_invalid;
19995 }
19996 384 }
19997 }
19998 125 }
19999
20000
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 2000 times.
2125 for(int32_t i=0; i<16; i++)
20001 {
20002
2/4
✓ Branch 0 taken 2000 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2000 times.
2000 if(!p_getc(&temp_zinit.misc[i],f))
20003 {
20004 return qe_invalid;
20005 }
20006 2000 }
20007
20008
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 48 times.
✓ Branch 3 taken 12 times.
173 if(s_version < 15) for(int32_t i=0; i<4; i++)
20009 {
20010
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&sword_hearts[i],f))
20011 {
20012 return qe_invalid;
20013 }
20014 60 }
20015
20016
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_map,f))
20017 {
20018 return qe_invalid;
20019 }
20020
20021
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.last_screen,f))
20022 {
20023 return qe_invalid;
20024 }
20025
20026
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version < 14)
20027 {
20028 byte tempmp;
20029
20030
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20031 {
20032 return qe_invalid;
20033 }
20034
20035 12 temp_zinit.max_magic=tempmp;
20036
20037
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempmp,f))
20038 {
20039 return qe_invalid;
20040 }
20041
20042 12 temp_zinit.magic=tempmp;
20043 12 }
20044 else
20045 {
20046
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_magic,f))
20047 {
20048 return qe_invalid;
20049 }
20050
20051
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.magic,f))
20052 {
20053 return qe_invalid;
20054 }
20055 }
20056
20057
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20058 {
20059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version < 12)
20060 {
20061 12 temp_zinit.max_magic*=32;
20062 12 temp_zinit.magic*=32;
20063 12 }
20064
20065
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20066 {
20067
2/4
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
48 if(!p_getc(&beam_hearts[i],f))
20068 {
20069 return qe_invalid;
20070 }
20071 48 }
20072
20073
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&beam_percent,f))
20074 {
20075 return qe_invalid;
20076 }
20077 12 }
20078 else
20079 {
20080
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.bomb_ratio,f))
20081 {
20082 return qe_invalid;
20083 }
20084 }
20085
20086
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version < 15)
20087 {
20088 byte tempbp;
20089
20090
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 48 times.
60 for(int32_t i=0; i<4; i++)
20091 {
20092
3/8
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
48 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
20093 {
20094 return qe_invalid;
20095 }
20096
20097 48 beam_power[i]=tempbp;
20098 48 }
20099
20100
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&hookshot_links,f))
20101 {
20102 return qe_invalid;
20103 }
20104
20105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if(s_version>6)
20106 {
20107 if(!p_getc(&hookshot_length,f))
20108 {
20109 return qe_invalid;
20110 }
20111
20112 if(!p_getc(&longshot_links,f))
20113 {
20114 return qe_invalid;
20115 }
20116
20117 if(!p_getc(&longshot_length,f))
20118 {
20119 return qe_invalid;
20120 }
20121 }
20122 12 }
20123
20124
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_x,f))
20125 {
20126 return qe_invalid;
20127 }
20128
20129
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.msg_more_y,f))
20130 {
20131 return qe_invalid;
20132 }
20133
20134
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.subscreen,f))
20135 {
20136 return qe_invalid;
20137 }
20138
20139 //old only
20140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20141 {
20142 for(int32_t i=0; i<32; i++)
20143 {
20144 if(!p_getc(&temp_zinit.boss_key[i],f))
20145 {
20146 return qe_invalid;
20147 }
20148 }
20149 }
20150
20151
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
125 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
20152 {
20153
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version <= 10)
20154 {
20155 byte tempbyte;
20156
20157
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
12 if(!p_getc(&tempbyte,f))
20158 {
20159 return qe_invalid;
20160 }
20161
20162 12 temp_zinit.start_dmap = (word)tempbyte;
20163 12 }
20164 else
20165 {
20166
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.start_dmap,f))
20167 {
20168 return qe_invalid;
20169 }
20170 }
20171
20172
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20173 {
20174 return qe_invalid;
20175 }
20176 125 }
20177
20178
4/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 77 times.
✓ Branch 3 taken 36 times.
125 if(s_version>1 && s_version < 29)
20179 {
20180
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20181 return qe_invalid;
20182 77 temp_zinit.arrows = padding;
20183
20184
2/4
✓ Branch 0 taken 77 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 77 times.
✗ Branch 3 not taken.
77 if(!p_getc(&padding,f))
20185 return qe_invalid;
20186 77 temp_zinit.max_arrows = padding;
20187 77 }
20188
20189
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 113 times.
125 if(s_version>2)
20190 {
20191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(s_version <= 10)
20192 {
20193 for(int32_t i=0; i<OLDMAXLEVELS; i++)
20194 {
20195 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20196 {
20197 return qe_invalid;
20198 }
20199 }
20200 }
20201 else
20202 {
20203
2/2
✓ Branch 0 taken 57856 times.
✓ Branch 1 taken 113 times.
57969 for(int32_t i=0; i<MAXLEVELS; i++)
20204 {
20205
2/4
✓ Branch 0 taken 57856 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 57856 times.
✗ Branch 3 not taken.
57856 if(!p_getc(&(temp_zinit.level_keys[i]),f))
20206 {
20207 return qe_invalid;
20208 }
20209 57856 }
20210 }
20211 113 }
20212
20213
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>3)
20214 {
20215
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_x,f))
20216 {
20217 return qe_invalid;
20218 }
20219
20220
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_y,f))
20221 {
20222 return qe_invalid;
20223 }
20224
20225
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
20226 {
20227 return qe_invalid;
20228 }
20229
20230
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
20231 {
20232 return qe_invalid;
20233 }
20234
20235
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_grid_color,f))
20236 {
20237 return qe_invalid;
20238 }
20239
20240
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
20241 {
20242 return qe_invalid;
20243 }
20244
20245
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
20246 {
20247 return qe_invalid;
20248 }
20249
20250
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.ss_flags,f))
20251 {
20252 return qe_invalid;
20253 }
20254
20255
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
20256
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
20257 113 }
20258
20259
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>4 && s_version<15)
20260 {
20261 if(!p_getc(&moving_fairy_hearts,f))
20262 {
20263 return qe_invalid;
20264 }
20265
20266 if(!p_getc(&moving_fairy_heart_percent,f))
20267 {
20268 return qe_invalid;
20269 }
20270 }
20271
20272
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>5 && s_version < 10)
20273 {
20274 if(!p_getc(&temp,f))
20275 {
20276 return qe_invalid;
20277 }
20278
20279 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
20280 }
20281
20282
3/4
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
125 if(s_version>6 && s_version<15)
20283 {
20284 if(!p_getc(&stationary_fairy_hearts,f))
20285 {
20286 return qe_invalid;
20287 }
20288
20289 if(!p_getc(&stationary_fairy_heart_percent,f))
20290 {
20291 return qe_invalid;
20292 }
20293
20294 if(!p_getc(&moving_fairy_magic,f))
20295 {
20296 return qe_invalid;
20297 }
20298
20299 if(!p_getc(&moving_fairy_magic_percent,f))
20300 {
20301 return qe_invalid;
20302 }
20303
20304 if(!p_getc(&stationary_fairy_magic,f))
20305 {
20306 return qe_invalid;
20307 }
20308
20309 if(!p_getc(&stationary_fairy_magic_percent,f))
20310 {
20311 return qe_invalid;
20312 }
20313
20314 if(!p_getc(&blue_potion_hearts,f))
20315 {
20316 return qe_invalid;
20317 }
20318
20319 if(!p_getc(&blue_potion_heart_percent,f))
20320 {
20321 return qe_invalid;
20322 }
20323
20324 if(!p_getc(&red_potion_hearts,f))
20325 {
20326 return qe_invalid;
20327 }
20328
20329 if(!p_getc(&red_potion_heart_percent,f))
20330 {
20331 return qe_invalid;
20332 }
20333
20334 if(!p_getc(&blue_potion_magic,f))
20335 {
20336 return qe_invalid;
20337 }
20338
20339 if(!p_getc(&blue_potion_magic_percent,f))
20340 {
20341 return qe_invalid;
20342 }
20343
20344 if(!p_getc(&red_potion_magic,f))
20345 {
20346 return qe_invalid;
20347 }
20348
20349 if(!p_getc(&red_potion_magic_percent,f))
20350 {
20351 return qe_invalid;
20352 }
20353 }
20354
20355
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>6)
20356 {
20357
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.subscreen_style,f))
20358 {
20359 return qe_invalid;
20360 }
20361 113 }
20362
20363
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>7)
20364 {
20365
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.usecustomsfx,f))
20366 {
20367 return qe_invalid;
20368 }
20369 113 }
20370
20371
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>8)
20372 {
20373
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_rupees,f))
20374 {
20375 return qe_invalid;
20376 }
20377
20378
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.max_keys,f))
20379 {
20380 return qe_invalid;
20381 }
20382 113 }
20383
20384
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>16)
20385 {
20386
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.gravity,f))
20387 {
20388 return qe_invalid;
20389 }
20390
20391
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_igetw(&temp_zinit.terminalv,f))
20392 {
20393 return qe_invalid;
20394 }
20395
20396
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_speed,f))
20397 {
20398 return qe_invalid;
20399 }
20400
20401
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.transition_type,f))
20402 {
20403 return qe_invalid;
20404 }
20405
20406
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20407 {
20408 return qe_invalid;
20409 }
20410 113 }
20411
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12 times.
12 else if (replay_version_check(0, 13))
20412 12 temp_zinit.msg_speed = 0;
20413
20414
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 12 times.
125 if(s_version>17)
20415 {
20416
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20417 {
20418 return qe_invalid;
20419 }
20420 113 }
20421
20422 //expaned init data for larger values in 2.55
20423
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20424 {
20425
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.bombs,f))
20426 {
20427 return qe_invalid;
20428 }
20429
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.super_bombs,f))
20430 {
20431 return qe_invalid;
20432 }
20433
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_bombs,f))
20434 {
20435 return qe_invalid;
20436 }
20437
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_sbombs,f))
20438 {
20439 return qe_invalid;
20440 }
20441
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.arrows,f))
20442 {
20443 return qe_invalid;
20444 }
20445
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.max_arrows,f))
20446 {
20447 return qe_invalid;
20448 }
20449
20450 36 }
20451
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 20 )
20452 {
20453
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroStep,f))
20454 {
20455 return qe_invalid;
20456 }
20457 36 }
20458 else
20459 {
20460 89 temp_zinit.heroStep = 150; //1.5 pixels per frame
20461 }
20462
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 89 times.
125 if ( s_version >= 21 )
20463 {
20464
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20465 {
20466 return qe_invalid;
20467 }
20468 36 }
20469 else
20470 {
20471 89 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20472 }
20473 //old only
20474
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
125 if((Header->zelda_version == 0x192)&&(Header->build<174))
20475 {
20476 byte items2;
20477
20478 if(!p_getc(&items2,f))
20479 {
20480 return qe_invalid;
20481 }
20482
20483 temp_zinit.items[iDivineFire]=(get_bit(&items2, idI_DFIRE)!=0);
20484 temp_zinit.items[iDivineEscape]=(get_bit(&items2, idI_FWIND)!=0);
20485 temp_zinit.items[iDivineProtection]=(get_bit(&items2, idI_NLOVE)!=0);
20486 }
20487
20488
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(Header->zelda_version < 0x193)
20489 {
20490 for(int32_t q=0; q<96; q++)
20491 {
20492 if(!p_getc(&padding,f))
20493 {
20494 return qe_invalid;
20495 }
20496 }
20497
20498 //new only
20499 if((Header->zelda_version == 0x192)&&(Header->build>173))
20500 {
20501 if(!p_getc(&padding,f))
20502 {
20503 return qe_invalid;
20504 }
20505
20506 if(!p_getc(&padding,f))
20507 {
20508 return qe_invalid;
20509 }
20510 }
20511 }
20512 125 }
20513
20514
3/6
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 69 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 113 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
182 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20515 {
20516 //temp_zinit.shield=i_smallshield;
20517
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 53 times.
69 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20518
20519
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 if(sshieldid != -1)
20520 16 temp_zinit.items[sshieldid] = true;
20521 16 }
20522
20523
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20524 {
20525 4 temp_zinit.hc=3;
20526 4 temp_zinit.start_heart=3;
20527 4 temp_zinit.cont_heart=3;
20528 4 temp_zinit.max_bombs=8;
20529 4 }
20530
20531
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20532 {
20533 4 sword_hearts[0]=0;
20534 4 sword_hearts[1]=5;
20535 4 sword_hearts[2]=12;
20536 4 sword_hearts[3]=21;
20537 4 }
20538
20539
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20540 {
20541 4 temp_zinit.last_map=0;
20542 4 temp_zinit.last_screen=0;
20543 4 }
20544
20545
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20546 {
20547 4 temp_zinit.max_magic=0;
20548 4 temp_zinit.magic=0;
20549
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20550 4 }
20551
20552
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20553 {
20554
20555
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t x=0; x<4; x++)
20556 {
20557 16 beam_hearts[x]=100;
20558 16 }
20559
20560
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4 times.
20 for(int32_t i=0; i<idBP_MAX; i++)
20561 {
20562
2/4
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
16 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20563
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 set_qr(qr_LENSHINTS+i,0);
20564 16 }
20565
20566
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 16 times.
20 for(int32_t x=0; x<4; x++)
20567 {
20568
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20569 16 }
20570
20571
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_HIDECARRIEDITEMS,0);
20572 4 hookshot_links=100;
20573 4 temp_zinit.msg_more_x=224;
20574 4 temp_zinit.msg_more_y=64;
20575 4 }
20576
20577 // Okay, let's put these legacy values into itemsbuf.
20578
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(s_version < 15)
20579
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 4096 times.
4112 for(int32_t i=0; i<MAXITEMS; i++)
20580 {
20581
11/11
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 16 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 16 times.
✓ Branch 6 taken 16 times.
✓ Branch 7 taken 16 times.
✓ Branch 8 taken 3936 times.
✓ Branch 9 taken 16 times.
✓ Branch 10 taken 16 times.
4096 switch(i)
20582 {
20583 case iFairyStill:
20584 16 itemsbuf[i].misc1 = stationary_fairy_hearts;
20585 16 itemsbuf[i].misc2 = stationary_fairy_magic;
20586 16 itemsbuf[i].misc3 = 0;
20587 16 itemsbuf[i].flags |= stationary_fairy_heart_percent ? ITEM_FLAG1 : 0;
20588 16 itemsbuf[i].flags |= stationary_fairy_magic_percent ? ITEM_FLAG2 : 0;
20589 16 break;
20590
20591 case iFairyMoving:
20592 16 itemsbuf[i].misc1 = moving_fairy_hearts;
20593 16 itemsbuf[i].misc2 = moving_fairy_magic;
20594 16 itemsbuf[i].misc3 = 50;
20595 16 itemsbuf[i].flags |= moving_fairy_heart_percent ? ITEM_FLAG1 : 0;
20596 16 itemsbuf[i].flags |= moving_fairy_magic_percent ? ITEM_FLAG2 : 0;
20597 16 break;
20598
20599 case iRPotion:
20600 16 itemsbuf[i].misc1 = red_potion_hearts;
20601 16 itemsbuf[i].misc2 = red_potion_magic;
20602 16 itemsbuf[i].flags |= red_potion_heart_percent ? ITEM_FLAG1 : 0;
20603 16 itemsbuf[i].flags |= red_potion_magic_percent ? ITEM_FLAG2 : 0;
20604 16 break;
20605
20606 case iBPotion:
20607 16 itemsbuf[i].misc1 = blue_potion_hearts;
20608 16 itemsbuf[i].misc2 = blue_potion_magic;
20609 16 itemsbuf[i].flags |= blue_potion_heart_percent ? ITEM_FLAG1 : 0;
20610 16 itemsbuf[i].flags |= blue_potion_magic_percent ? ITEM_FLAG2 : 0;
20611 16 break;
20612
20613 case iSword:
20614 16 itemsbuf[i].pickup_hearts = sword_hearts[0];
20615 16 itemsbuf[i].misc1 = beam_hearts[0];
20616 16 itemsbuf[i].misc2 = beam_power[0];
20617 // It seems that ITEM_FLAG1 was already added by reset_itembuf()...
20618
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~ITEM_FLAG1 : ~0;
20619 16 break;
20620
20621 case iWSword:
20622 16 itemsbuf[i].pickup_hearts = sword_hearts[1];
20623 16 itemsbuf[i].misc1 = beam_hearts[1];
20624 16 itemsbuf[i].misc2 = beam_power[1];
20625
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~ITEM_FLAG1 : ~0;
20626 16 break;
20627
20628 case iMSword:
20629 16 itemsbuf[i].pickup_hearts = sword_hearts[2];
20630 16 itemsbuf[i].misc1 = beam_hearts[2];
20631 16 itemsbuf[i].misc2 = beam_power[2];
20632
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~ITEM_FLAG1 : ~0;
20633 16 break;
20634
20635 case iXSword:
20636 16 itemsbuf[i].pickup_hearts = sword_hearts[3];
20637 16 itemsbuf[i].misc1 = beam_hearts[3];
20638 16 itemsbuf[i].misc2 = beam_power[3];
20639
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~ITEM_FLAG1 : ~0;
20640 16 break;
20641
20642 case iHookshot:
20643 16 itemsbuf[i].misc1 = hookshot_length;
20644 16 itemsbuf[i].misc2 = hookshot_links;
20645 16 break;
20646
20647 case iLongshot:
20648 16 itemsbuf[i].misc1 = longshot_length;
20649 16 itemsbuf[i].misc2 = longshot_links;
20650 16 break;
20651 }
20652 4112 }
20653
20654
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20655 {
20656 //was new subscreen rule
20657
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.subscreen=get_qr(qr_FREEFORM)?1:0;
20658
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 set_qr(qr_FREEFORM,0);
20659 4 }
20660
20661
3/4
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20662 {
20663 4 temp_zinit.start_dmap=0;
20664 4 }
20665
20666
3/6
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20667 {
20668
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20669 4 }
20670
20671
4/6
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 113 times.
✓ Branch 2 taken 16 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
129 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20672 {
20673 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20674 temp_zinit.max_rupees=999;
20675 //temp_zinit.rupies=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20676 }
20677
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20678 {
20679 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20680 temp_zinit.max_bombs = 8;
20681 }
20682 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20683 //time to ensure that we port all new values properly:
20684
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 16 times.
129 if(Header->zelda_version < 0x250)
20685 {
20686
1/2
✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
16 temp_zinit.max_sbombs = temp_zinit.bomb_ratio > 0 ? ( temp_zinit.max_bombs/temp_zinit.bomb_ratio ) : (temp_zinit.max_bombs/4);
20687 16 }
20688
20689
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 21)
20690 {
20691
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hp_per_heart,f))
20692 {
20693 return qe_invalid;
20694 }
20695
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magic_per_block,f))
20696 {
20697 return qe_invalid;
20698 }
20699
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20700 {
20701 return qe_invalid;
20702 }
20703
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20704 {
20705 return qe_invalid;
20706 }
20707 36 }
20708 else
20709 {
20710 93 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20711 93 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20712 93 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20713 93 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20714 }
20715
20716
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 22)
20717 {
20718
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20719 {
20720
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrcnt[q],f))
20721 {
20722 return qe_invalid;
20723 }
20724 900 }
20725
2/2
✓ Branch 0 taken 900 times.
✓ Branch 1 taken 36 times.
936 for(int32_t q = 0; q < 25; ++q)
20726 {
20727
2/4
✓ Branch 0 taken 900 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 900 times.
900 if(!p_igetw(&temp_zinit.scrmaxcnt[q],f))
20728 {
20729 return qe_invalid;
20730 }
20731 900 }
20732 36 }
20733 else
20734 {
20735
2/2
✓ Branch 0 taken 2325 times.
✓ Branch 1 taken 93 times.
2418 for(int32_t q = 0; q < 25; ++q)
20736 {
20737 2325 temp_zinit.scrcnt[q] = 0;
20738 2325 temp_zinit.scrmaxcnt[q] = 0;
20739 2325 }
20740 }
20741
20742
20743
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 23)
20744 {
20745
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_type,f))
20746 {
20747 return qe_invalid;
20748 }
20749
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_arg,f))
20750 {
20751 return qe_invalid;
20752 }
20753
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.dither_percent,f))
20754 {
20755 return qe_invalid;
20756 }
20757
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.def_lightrad,f))
20758 {
20759 return qe_invalid;
20760 }
20761
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.transdark_percent,f))
20762 {
20763 return qe_invalid;
20764 }
20765 36 }
20766 else
20767 {
20768 93 temp_zinit.dither_type = 0;
20769 93 temp_zinit.dither_arg = 0;
20770 93 temp_zinit.dither_percent = 20;
20771 93 temp_zinit.def_lightrad = 24;
20772 93 temp_zinit.transdark_percent = 0;
20773 }
20774
20775
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 24)
20776 {
20777
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.darkcol,f))
20778 {
20779 return qe_invalid;
20780 }
20781 36 }
20782 else
20783 {
20784 93 temp_zinit.darkcol = BLACK;
20785 }
20786
20787
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 25)
20788 {
20789
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.gravity2,f))
20790 {
20791 return qe_invalid;
20792 }
20793
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.swimgravity,f))
20794 {
20795 return qe_invalid;
20796 }
20797 36 }
20798 else
20799 {
20800 93 temp_zinit.gravity2 = temp_zinit.gravity*100;
20801 93 temp_zinit.swimgravity = 5;
20802 }
20803
20804
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 26)
20805 {
20806
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20807 {
20808 return qe_invalid;
20809 }
20810
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20811 {
20812 return qe_invalid;
20813 }
20814
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20815 {
20816 return qe_invalid;
20817 }
20818 36 }
20819 else
20820 {
20821 93 temp_zinit.heroSideswimUpStep = 150;
20822 93 temp_zinit.heroSideswimSideStep = 100;
20823 93 temp_zinit.heroSideswimDownStep = 75;
20824 }
20825
20826
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 27)
20827 {
20828
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20829 {
20830 return qe_invalid;
20831 }
20832 36 }
20833 else
20834 {
20835 93 temp_zinit.exitWaterJump = 0;
20836 }
20837
20838
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 29)
20839 {
20840
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20841 {
20842 return qe_invalid;
20843 }
20844 36 }
20845 else
20846 {
20847 93 temp_zinit.bunny_ltm = 0;
20848 }
20849
20850
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 30)
20851 {
20852
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.switchhookstyle,f))
20853 {
20854 return qe_invalid;
20855 }
20856 36 }
20857 else
20858 {
20859 93 temp_zinit.switchhookstyle = 1;
20860 }
20861
20862
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 93 times.
129 if(s_version > 31)
20863 {
20864
2/4
✓ Branch 0 taken 36 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 36 times.
✗ Branch 3 not taken.
36 if(!p_getc(&temp_zinit.magicdrainrate,f))
20865 {
20866 return qe_invalid;
20867 }
20868 36 }
20869 else
20870 {
20871
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 temp_zinit.magicdrainrate = (get_bit(temp_zinit.misc,idM_DOUBLEMAGIC) ? 1 : 2);
20872
1/2
✓ Branch 0 taken 93 times.
✗ Branch 1 not taken.
93 set_bit(temp_zinit.misc,idM_DOUBLEMAGIC,0);
20873 }
20874
20875
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 temp_zinit.clear_genscript();
20876
2/2
✓ Branch 0 taken 34 times.
✓ Branch 1 taken 95 times.
129 if(s_version > 32)
20877 {
20878 34 word numgenscript = 0;
20879
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 34 times.
✗ Branch 3 not taken.
34 if(!p_igetw(&numgenscript,f))
20880 return qe_invalid;
20881
2/4
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 34 times.
34 if (!(numgenscript >= 0 && numgenscript <= NUMSCRIPTSGENERIC))
20882 return qe_invalid;
20883
1/2
✓ Branch 0 taken 34 times.
✗ Branch 1 not taken.
34 for(auto q = 1; q < numgenscript; ++q)
20884 {
20885 if(!p_getc(&padding,f))
20886 return qe_invalid;
20887 if(!(padding&2))
20888 continue;
20889 temp_zinit.gen_doscript[q] = padding&1;
20890 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20891 return qe_invalid;
20892 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20893 return qe_invalid;
20894 for(auto p = 0; p < 8; ++p)
20895 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20896 return qe_invalid;
20897 if(!p_igetl(&temp_zinit.gen_dataSize[q],f))
20898 return qe_invalid;
20899 if(!p_getlvec<int32_t>(&temp_zinit.gen_data[q],f))
20900 return qe_invalid;
20901 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20902 return qe_invalid;
20903 }
20904 34 }
20905
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 98 times.
129 if(s_version > 33)
20906 {
20907
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20908 return qe_invalid;
20909
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if(!p_getc(&temp_zinit.hero_swim_div,f))
20910 return qe_invalid;
20911 31 }
20912
20913
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 zinit = temp_zinit;
20914
20915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(zinit.heroAnimationStyle==las_zelda3slow)
20916 {
20917 hero_animation_speed=2;
20918 }
20919 else
20920 {
20921 129 hero_animation_speed=1;
20922 }
20923
20924 129 return 0;
20925 485 }
20926
20927 /*
20928 void setupitemdropsets()
20929 {
20930 for(int32_t i=0; i<isMAX; i++)
20931 {
20932 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20933 }
20934 }
20935 */
20936
20937 117 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20938 {
20939 117 build=build; // here to prevent compiler warnings
20940 dword dummy_dword;
20941 117 word item_drop_sets_to_read=0;
20942 item_drop_object tempitemdrop;
20943 117 word s_version=0, s_cversion=0;
20944
20945
2/2
✓ Branch 0 taken 29952 times.
✓ Branch 1 taken 117 times.
30069 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20946 {
20947 29952 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20948 29952 }
20949
20950
2/2
✓ Branch 0 taken 113 times.
✓ Branch 1 taken 4 times.
117 if(version > 0x192)
20951 {
20952 113 item_drop_sets_to_read=0;
20953
20954 //section version info
20955
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_version,f))
20956 {
20957 return qe_invalid;
20958 }
20959
20960 113 FFCore.quest_format[vItemDropsets] = s_version;
20961
20962 //al_trace("Item drop sets version %d\n", s_version);
20963
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
20964 {
20965 return qe_invalid;
20966 }
20967
20968 //section size
20969
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
20970 {
20971 return qe_invalid;
20972 }
20973
20974 //finally... section data
20975
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&item_drop_sets_to_read,f))
20976 {
20977 return qe_invalid;
20978 }
20979
20980
2/4
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
113 if (!(item_drop_sets_to_read >= 0 && item_drop_sets_to_read <= MAXITEMDROPSETS))
20981 {
20982 return qe_invalid;
20983 }
20984 113 }
20985 else
20986 {
20987 4 init_item_drop_sets();
20988 }
20989
20990
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 113 times.
117 if(s_version>=1)
20991 {
20992
2/2
✓ Branch 0 taken 2069 times.
✓ Branch 1 taken 113 times.
2182 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20993 {
20994
1/2
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
2069 if(!pfread(tempitemdrop.name,sizeof(tempitemdrop.name),f))
20995 {
20996 return qe_invalid;
20997 }
20998
20999
2/2
✓ Branch 0 taken 20690 times.
✓ Branch 1 taken 2069 times.
22759 for(int32_t j=0; j<10; ++j)
21000 {
21001
1/2
✓ Branch 0 taken 20690 times.
✗ Branch 1 not taken.
20690 if(!p_igetw(&tempitemdrop.item[j],f))
21002 {
21003 return qe_invalid;
21004 }
21005 20690 }
21006
21007
2/2
✓ Branch 0 taken 22759 times.
✓ Branch 1 taken 2069 times.
24828 for(int32_t j=0; j<11; ++j)
21008 {
21009
1/2
✓ Branch 0 taken 22759 times.
✗ Branch 1 not taken.
22759 if(!p_igetw(&tempitemdrop.chance[j],f))
21010 {
21011 return qe_invalid;
21012 }
21013 22759 }
21014
21015 // Dec 2008: Addition of the 'Tall Grass' set, #12,
21016 // overrides the quest's set #12.
21017
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 2069 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2 && i==12)
21018 continue;
21019
21020 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
21021
1/4
✓ Branch 0 taken 2069 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
2069 if(s_version<2) for(int32_t j=0; j<10; ++j)
21022 {
21023 int32_t it = tempitemdrop.item[j];
21024
21025 if((itemsbuf[it].family == itype_rupee
21026 && ((itemsbuf[it].amount)&0xFFF) == 10)
21027 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
21028 {
21029 tempitemdrop.chance[j+1]=0;
21030 }
21031 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
21032 {
21033 tempitemdrop.chance[j+1]=0;
21034 }
21035
21036 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
21037 if(itemsbuf[it].family == itype_misc)
21038 {
21039 // If a non-gameplay item was selected, then item drop was aborted.
21040 // Reflect this by increasing the 'Nothing' chance accordingly.
21041 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
21042 tempitemdrop.chance[j+1]=0;
21043 }
21044 }
21045
21046 2069 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
21047 2069 }
21048 113 }
21049
21050 117 return 0;
21051 117 }
21052
21053 113 int32_t readfavorites(PACKFILE *f, int32_t, word)
21054 {
21055 int32_t temp_num;
21056 dword dummy_dword;
21057 word num_favorite_combos;
21058 word num_favorite_combo_aliases;
21059 113 word s_version=0, s_cversion=0;
21060
21061 //section version info
21062
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(!p_igetw(&s_version,f))
21063 {
21064 return qe_invalid;
21065 }
21066
21067 113 FFCore.quest_format[vFavourites] = s_version;
21068
21069
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&s_cversion,f))
21070 {
21071 return qe_invalid;
21072 }
21073
21074 //section size
21075
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetl(&dummy_dword,f))
21076 {
21077 return qe_invalid;
21078 }
21079
21080 113 word per_row = FAVORITECOMBO_PER_ROW;
21081
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 3)
21082
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&per_row,f))
21083 return qe_invalid;
21084 //finally... section data
21085
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combos,f))
21086 {
21087 return qe_invalid;
21088 }
21089
21090 //Hack; port old favorite combos
21091
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 82 times.
113 if(s_version < 3 && num_favorite_combos == 100)
21092 82 per_row = 13;
21093
21094
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
21095 33900 favorite_combos[q] = -1;
21096
2/2
✓ Branch 0 taken 33900 times.
✓ Branch 1 taken 113 times.
34013 for(int q = 0; q < MAXFAVORITECOMBOALIASES; ++q)
21097 33900 favorite_comboaliases[q] = -1;
21098
2/2
✓ Branch 0 taken 8735 times.
✓ Branch 1 taken 113 times.
8848 for(int32_t i=0; i<num_favorite_combos; i++)
21099 {
21100
1/2
✓ Branch 0 taken 8735 times.
✗ Branch 1 not taken.
8735 if(!p_igetl(&temp_num,f))
21101 {
21102 return qe_invalid;
21103 }
21104
21105
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 8200 times.
8735 if(per_row == FAVORITECOMBO_PER_ROW)
21106 535 favorite_combos[i]=temp_num;
21107 else
21108 {
21109 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21110 8200 favorite_combos[new_i]=temp_num;
21111 }
21112 8735 }
21113
21114
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 if(!p_igetw(&num_favorite_combo_aliases,f))
21115 {
21116 return qe_invalid;
21117 }
21118
21119
2/2
✓ Branch 0 taken 8200 times.
✓ Branch 1 taken 113 times.
8313 for(int32_t i=0; i<num_favorite_combo_aliases; i++)
21120 {
21121
1/2
✓ Branch 0 taken 8200 times.
✗ Branch 1 not taken.
8200 if(!p_igetl(&temp_num,f))
21122 {
21123 return qe_invalid;
21124 }
21125
21126
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8200 times.
8200 if(per_row == FAVORITECOMBO_PER_ROW)
21127 favorite_comboaliases[i]=temp_num;
21128 else
21129 {
21130 8200 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
21131 8200 favorite_comboaliases[new_i]=temp_num;
21132 }
21133 8200 }
21134
21135 113 word max_combo_cols = 0;
21136 113 word max_mappages = 0;
21137
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 31 times.
113 if(s_version >= 2)
21138 {
21139
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_combo_cols,f))
21140 return qe_invalid;
21141 31 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
21142
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 31 times.
155 for(int q = 0; q < max_combo_cols; ++q)
21143 {
21144
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp,f))
21145 return qe_invalid;
21146
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp2,f))
21147 return qe_invalid;
21148
1/2
✓ Branch 0 taken 124 times.
✗ Branch 1 not taken.
124 if(!p_igetl(&tmp3,f))
21149 return qe_invalid;
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 124 times.
124 if(q < MAX_COMBO_COLS)
21151 {
21152 124 First[q] = tmp;
21153 124 combo_alistpos[q] = tmp2;
21154 124 combo_pool_listpos[q] = tmp3;
21155 124 }
21156 124 }
21157
21158
1/2
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
31 if(!p_igetw(&max_mappages,f))
21159 return qe_invalid;
21160
2/2
✓ Branch 0 taken 279 times.
✓ Branch 1 taken 31 times.
310 for(int q = 0; q < max_mappages; ++q)
21161 {
21162
1/2
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
279 if(!p_igetl(&tmp,f))
21163 return qe_invalid;
21164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(!p_igetl(&tmp2,f))
21165 return qe_invalid;
21166
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 279 times.
279 if(q < MAX_MAPPAGE_BTNS)
21167 {
21168 279 map_page[q].map = tmp;
21169 279 map_page[q].screen = tmp2;
21170 279 }
21171 279 }
21172 31 }
21173
21174
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 113 times.
441 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21175 {
21176 328 First[q] = 0;
21177 328 combo_alistpos[q] = 0;
21178 328 combo_pool_listpos[q] = 0;
21179 328 }
21180
2/2
✓ Branch 0 taken 738 times.
✓ Branch 1 taken 113 times.
851 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21181 {
21182 738 map_page[q].map = 0;
21183 738 map_page[q].screen = 0;
21184 738 }
21185
21186 113 return 0;
21187 113 }
21188
21189 /*
21190 switch (ret) {
21191 case 0:
21192 break;
21193
21194 case qe_invalid:
21195 goto invalid;
21196 break;
21197 default:
21198 pack_fclose(f);
21199 if(!oldquest)
21200 delete_file(tmpfilename);
21201 return ret;
21202 break;
21203 }
21204 */
21205
21206 const char *skip_text[skip_max]=
21207 {
21208 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21209 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21210 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21211 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21212 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21213 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21214 "skip_favorites"
21215 };
21216
21217
21218 void port250QuestRules(){
21219
21220 portCandleRules(); //Candle
21221 portBombRules();
21222
21223 }
21224
21225 void portCandleRules()
21226 {
21227 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21228 //itemdata itemsbuf;
21229 for ( int32_t q = 0; q < MAXITEMS; q++ )
21230 {
21231 if ( itemsbuf[q].family == itype_candle )
21232 {
21233 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21234 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21235 }
21236 }
21237 }
21238
21239 void portBombRules()
21240 {
21241 bool hurtshero = get_qr(qr_OUCHBOMBS);
21242 //itemdata itemsbuf;
21243 for ( int32_t q = 0; q < MAXITEMS; q++ )
21244 {
21245 if ( itemsbuf[q].family == itype_bomb )
21246 {
21247 if ( hurtshero ) itemsbuf[q].flags |= ITEM_FLAG2;
21248 else itemsbuf[q].flags &= ~ ITEM_FLAG2;
21249 }
21250 }
21251 }
21252
21253 2892 static int section_id_to_enum(int id)
21254 {
21255
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 125 times.
✓ Branch 6 taken 113 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 125 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 113 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 125 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 113 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 125 times.
✓ Branch 23 taken 113 times.
✓ Branch 24 taken 113 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
2892 switch (id)
21256 {
21257 case ID_HEADER: return skip_header;
21258 125 case ID_RULES: return skip_rules;
21259 125 case ID_STRINGS: return skip_strings;
21260 125 case ID_MISC: return skip_misc;
21261 125 case ID_TILES: return skip_tiles;
21262 125 case ID_COMBOS: return skip_combos;
21263 113 case ID_COMBOALIASES: return skip_comboaliases;
21264 125 case ID_CSETS: return skip_csets;
21265 125 case ID_MAPS: return skip_maps;
21266 125 case ID_DMAPS: return skip_dmaps;
21267 125 case ID_DOORS: return skip_doors;
21268 125 case ID_ITEMS: return skip_items;
21269 125 case ID_WEAPONS: return skip_weapons;
21270 113 case ID_COLORS: return skip_colors;
21271 113 case ID_ICONS: return skip_icons;
21272 125 case ID_INITDATA: return skip_initdata;
21273 125 case ID_GUYS: return skip_guys;
21274 113 case ID_HEROSPRITES: return skip_herosprites;
21275 113 case ID_SUBSCREEN: return skip_subscreens;
21276 113 case ID_FFSCRIPT: return skip_ffscript;
21277 113 case ID_SFX: return skip_sfx;
21278 125 case ID_MIDIS: return skip_midis;
21279 125 case ID_CHEATS: return skip_cheats;
21280 113 case ID_ITEMDROPSETS: return skip_itemdropsets;
21281 113 case ID_FAVORITES: return skip_favorites;
21282 case ID_ZINFO: return skip_zinfo;
21283 }
21284
21285 return -1;
21286 2892 }
21287
21288 2892 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21289 {
21290 2892 int section_enum = section_id_to_enum(section_id);
21291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2892 times.
2892 if (skip)
21293 {
21294 word s_version;
21295 if (!p_igetw(&s_version,f))
21296 {
21297 return qe_invalid;
21298 }
21299
21300 word c_version;
21301 if (!p_igetw(&c_version,f))
21302 {
21303 return qe_invalid;
21304 }
21305
21306 if (section_id == ID_RULES && s_version > 16)
21307 {
21308 dword dummy;
21309 if (!p_igetl(&dummy,f))
21310 {
21311 return qe_invalid;
21312 }
21313 }
21314
21315 if (section_id == ID_FFSCRIPT && s_version >= 18)
21316 {
21317 word dummy;
21318 if (!p_igetw(&dummy,f))
21319 {
21320 return qe_invalid;
21321 }
21322 }
21323
21324 dword section_length;
21325 if (!p_igetl(&section_length,f))
21326 {
21327 return qe_invalid;
21328 }
21329
21330 if (pack_fseek(f, section_length))
21331 {
21332 return qe_invalid;
21333 }
21334
21335 if (!pack_feof(f))
21336 {
21337 if (!p_mgetl(&section_id,f))
21338 {
21339 return qe_invalid;
21340 }
21341 }
21342
21343 return qe_cancel;
21344 }
21345
21346 2892 return qe_OK;
21347 2892 }
21348
21349 //Internal function for loadquest wrapper
21350 129 int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, const byte *skip_flags, byte printmetadata)
21351 {
21352 129 DMapEditorLastMaptileUsed = 0;
21353 129 combosread=false;
21354 129 mapsread=false;
21355 129 fixffcs=false;
21356
21357 // show_progress=true;
21358 char tmpfilename[L_tmpnam];
21359 129 temp_name(tmpfilename);
21360 // char percent_done[30];
21361 129 bool catchup=false;
21362 byte tempbyte;
21363 129 word old_map_count=map_count;
21364
21365 129 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21366 129 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21367 129 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21368
21369
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
21370 {
21371 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21372 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21373 }
21374
21375 129 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21376 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21377
21378
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
21379 {
21380 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21381 }
21382
21383
21384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_ffscript))
21385 {
21386 129 zScript.clear();
21387 129 globalmap.clear();
21388 129 genericmap.clear();
21389 129 ffcmap.clear();
21390 129 itemmap.clear();
21391 129 npcmap.clear();
21392 129 ewpnmap.clear();
21393 129 lwpnmap.clear();
21394 129 playermap.clear();
21395 129 dmapmap.clear();
21396 129 screenmap.clear();
21397 129 itemspritemap.clear();
21398 129 comboscriptmap.clear();
21399
21400
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21401 {
21402 65919 ffcmap[i].clear();
21403 65919 }
21404
21405 129 globalmap[0].slotname = "Slot 1:";
21406 129 globalmap[0].scriptname = "~Init";
21407 129 globalmap[0].update();
21408
21409
2/2
✓ Branch 0 taken 903 times.
✓ Branch 1 taken 129 times.
1032 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21410 {
21411 903 globalmap[i].clear();
21412 903 }
21413
21414
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21415 {
21416 32895 itemmap[i].clear();
21417 32895 }
21418
21419 //new script types -- prevent carrying over to a quest that you load after reading them
21420 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21421
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21422 {
21423 32895 npcmap[i].clear();
21424 32895 }
21425
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21426 {
21427 32895 lwpnmap[i].clear();
21428 32895 }
21429
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21430 {
21431 32895 ewpnmap[i].clear();
21432 32895 }
21433
2/2
✓ Branch 0 taken 516 times.
✓ Branch 1 taken 129 times.
645 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21434 {
21435 516 playermap[i].clear();
21436 516 }
21437
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21438 {
21439 32895 dmapmap[i].clear();
21440 32895 }
21441
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21442 {
21443 32895 screenmap[i].clear();
21444 32895 }
21445
2/2
✓ Branch 0 taken 32895 times.
✓ Branch 1 taken 129 times.
33024 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21446 {
21447 32895 itemspritemap[i].clear();
21448 32895 }
21449
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21450 {
21451 65919 comboscriptmap[i].clear();
21452 65919 }
21453
2/2
✓ Branch 0 taken 65919 times.
✓ Branch 1 taken 129 times.
66048 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21454 {
21455 65919 genericmap[i].clear();
21456 65919 }
21457
21458 129 reset_scripts();
21459 129 }
21460
21461 zquestheader tempheader;
21462 129 memset(&tempheader, 0, sizeof(zquestheader));
21463 129 zinfo tempzi;
21464 129 tempzi.clear();
21465 129 load_tmp_zi = &tempzi;
21466
21467 // oldquest flag is set when an unencrypted qst file is suspected.
21468 129 bool oldquest = false;
21469 129 int32_t open_error=0;
21470 129 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21471
21472
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!f)
21473 {
21474 ASSERT(open_error != 0);
21475 return open_error;
21476 }
21477 char zinfofilename[2048];
21478 129 replace_extension(zinfofilename, filename, "zinfo", 2047);
21479 129 int32_t ret=0;
21480
21481 //header
21482 129 box_out("Reading Header...");
21483 129 ret=readheader(f, &tempheader, printmetadata);
21484
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
129 checkstatus(ret);
21485 129 box_out("okay.");
21486 129 box_eol();
21487
21488
2/2
✓ Branch 0 taken 93 times.
✓ Branch 1 taken 36 times.
129 if(read_zinfo)
21489 {
21490 36 box_out("Reading ZInfo - ");
21491
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 box_out(read_ext_zinfo ? "External..." : "Internal...");
21492
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 35 times.
36 if(read_ext_zinfo)
21493 {
21494 1 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21495 1 ret=readzinfo(inf, tempzi, tempheader);
21496
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(inf) pack_fclose(inf);
21497
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
1 checkstatus(ret);
21498 1 }
21499 else
21500 {
21501 35 ret=readzinfo(f, tempzi, tempheader);
21502
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 35 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
35 checkstatus(ret);
21503 }
21504 36 box_out("okay.");
21505 36 box_eol();
21506 36 }
21507
21508
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if(tempheader.zelda_version>=0x193)
21509 {
21510 dword section_id;
21511
21512 //section id
21513
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 if(!p_mgetl(&section_id,f))
21514 {
21515 return qe_invalid;
21516 }
21517
21518 125 std::set<dword> seen_sections;
21519
21520
3/4
✓ Branch 0 taken 3017 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✓ Branch 3 taken 125 times.
3017 while(!pack_feof(f))
21521 {
21522
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (seen_sections.contains(section_id))
21523 return qe_invalid;
21524
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 seen_sections.insert(section_id);
21525
21526
2/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2892 times.
✗ Branch 3 not taken.
2892 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21527 {
21528 if (retval == qe_cancel)
21529 continue;
21530 checkstatus(retval);
21531 }
21532
21533
24/25
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 125 times.
✓ Branch 2 taken 125 times.
✓ Branch 3 taken 125 times.
✓ Branch 4 taken 125 times.
✓ Branch 5 taken 113 times.
✓ Branch 6 taken 125 times.
✓ Branch 7 taken 125 times.
✓ Branch 8 taken 125 times.
✓ Branch 9 taken 125 times.
✓ Branch 10 taken 125 times.
✓ Branch 11 taken 125 times.
✓ Branch 12 taken 113 times.
✓ Branch 13 taken 113 times.
✓ Branch 14 taken 125 times.
✓ Branch 15 taken 125 times.
✓ Branch 16 taken 113 times.
✓ Branch 17 taken 113 times.
✓ Branch 18 taken 113 times.
✓ Branch 19 taken 113 times.
✓ Branch 20 taken 125 times.
✓ Branch 21 taken 125 times.
✓ Branch 22 taken 113 times.
✓ Branch 23 taken 113 times.
✗ Branch 24 not taken.
2892 switch(section_id)
21534 {
21535 case ID_RULES:
21536
21537 //rules
21538
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21539 {
21540 box_out("found.");
21541 box_eol();
21542 catchup=false;
21543 }
21544
21545
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Rules...");
21546
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readrules(f, &tempheader);
21547
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21548
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21549
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21550 125 break;
21551
21552 case ID_STRINGS:
21553
21554 //strings
21555
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21556 {
21557 box_out("found.");
21558 box_eol();
21559 catchup=false;
21560 }
21561
21562
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Strings...");
21563
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readstrings(f, &tempheader);
21564
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21565
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21566
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21567 125 break;
21568
21569 case ID_MISC:
21570
21571 //misc data
21572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21573 {
21574 box_out("found.");
21575 box_eol();
21576 catchup=false;
21577 }
21578
21579
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Misc. Data...");
21580
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmisc(f, &tempheader, Misc);
21581
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21582
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21583
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21584 125 break;
21585
21586 case ID_TILES:
21587
21588 //tiles
21589
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21590 {
21591 box_out("found.");
21592 box_eol();
21593 catchup=false;
21594 }
21595
21596
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tiles...");
21597
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21598
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21599
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21600
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21601 125 break;
21602
21603 case ID_COMBOS:
21604
21605 //combos
21606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21607 {
21608 box_out("found.");
21609 box_eol();
21610 catchup=false;
21611 }
21612
21613
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Combos...");
21614
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21615 125 combosread=true;
21616
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21617
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21618
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21619 125 break;
21620
21621 case ID_COMBOALIASES:
21622
21623 //combo aliases
21624
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21625 {
21626 box_out("found.");
21627 box_eol();
21628 catchup=false;
21629 }
21630
21631
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Combo Aliases...");
21632
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21633
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21634
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21635
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21636 113 break;
21637
21638 case ID_CSETS:
21639
21640 //color data
21641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21642 {
21643 box_out("found.");
21644 box_eol();
21645 catchup=false;
21646 }
21647
21648
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Color Data...");
21649
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21650
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21651
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21652
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21653 125 break;
21654
21655 case ID_MAPS:
21656
21657 //maps
21658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21659 {
21660 box_out("found.");
21661 box_eol();
21662 catchup=false;
21663 }
21664
21665
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Maps...");
21666
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readmaps(f, &tempheader);
21667 125 mapsread=true;
21668
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21669
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21670
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21671 125 break;
21672
21673 case ID_DMAPS:
21674
21675 //dmaps
21676
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21677 {
21678 box_out("found.");
21679 box_eol();
21680 catchup=false;
21681 }
21682
21683
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading DMaps...");
21684
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21685
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21686
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21687
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21688 125 break;
21689
21690 case ID_DOORS:
21691
21692 //door combo sets
21693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21694 {
21695 box_out("found.");
21696 box_eol();
21697 catchup=false;
21698 }
21699
21700
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Doors...");
21701
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readdoorcombosets(f, &tempheader);
21702
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21703
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21704
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21705 125 break;
21706
21707 case ID_ITEMS:
21708
21709 //items
21710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21711 {
21712 box_out("found.");
21713 box_eol();
21714 catchup=false;
21715 }
21716
21717
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Items...");
21718
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21719
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21720
21721
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21722
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21723 125 break;
21724
21725 case ID_WEAPONS:
21726
21727 //weapons
21728
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21729 {
21730 box_out("found.");
21731 box_eol();
21732 catchup=false;
21733 }
21734
21735
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Weapons...");
21736
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readweapons(f, &tempheader);
21737
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21738
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21739
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21740 125 break;
21741
21742 case ID_COLORS:
21743
21744 //misc. colors
21745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21746 {
21747 box_out("found.");
21748 box_eol();
21749 catchup=false;
21750 }
21751
21752
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Misc. Colors...");
21753
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readmisccolors(f, &tempheader, Misc);
21754
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21755
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21756
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21757 113 break;
21758
21759 case ID_ICONS:
21760
21761 //game icons
21762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21763 {
21764 box_out("found.");
21765 box_eol();
21766 catchup=false;
21767 }
21768
21769
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Game Icons...");
21770
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readgameicons(f, &tempheader, Misc);
21771
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21772
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21773
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21774 113 break;
21775
21776 case ID_INITDATA:
21777
21778 //initialization data
21779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21780 {
21781 box_out("found.");
21782 box_eol();
21783 catchup=false;
21784 }
21785
21786
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Init. Data...");
21787
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readinitdata(f, &tempheader);
21788
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21789
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21790
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21791
21792
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_subscreens))
21793 {
21794
2/2
✓ Branch 0 taken 27 times.
✓ Branch 1 taken 98 times.
125 if(zinit.subscreen!=ssdtMAX) //not using custom subscreens
21795 {
21796
1/2
✓ Branch 0 taken 27 times.
✗ Branch 1 not taken.
27 setupsubscreens();
21797
21798
2/2
✓ Branch 0 taken 13824 times.
✓ Branch 1 taken 27 times.
13851 for(int32_t i=0; i<MAXDMAPS; ++i)
21799 {
21800 13824 int32_t type=DMaps[i].type&dmfTYPE;
21801
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 13617 times.
13824 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21802
1/2
✓ Branch 0 taken 13824 times.
✗ Branch 1 not taken.
13824 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21803 13824 }
21804 27 }
21805 125 }
21806
21807
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_sfx))
21808 {
21809 125 setupsfx();
21810 125 }
21811
21812
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
125 if(!get_bit(skip_flags, skip_itemdropsets))
21813 {
21814
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 init_item_drop_sets();
21815 125 }
21816
21817
2/4
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 125 times.
125 if(!get_bit(skip_flags, skip_favorites))
21818 {
21819 125 init_favorites();
21820 125 }
21821
21822 125 break;
21823
21824 case ID_GUYS:
21825
21826 //guys
21827
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21828 {
21829 box_out("found.");
21830 box_eol();
21831 catchup=false;
21832 }
21833
21834
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Custom Guy Data...");
21835
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readguys(f, &tempheader);
21836
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21837
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21838
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21839 125 break;
21840
21841 case ID_HEROSPRITES:
21842
21843 //player sprites
21844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21845 {
21846 box_out("found.");
21847 box_eol();
21848 catchup=false;
21849 }
21850
21851
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Player Sprite Data...");
21852
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readherosprites(f, &tempheader);
21853
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21854
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21855
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21856 113 break;
21857
21858 case ID_SUBSCREEN:
21859
21860 //custom subscreens
21861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21862 {
21863 box_out("found.");
21864 box_eol();
21865 catchup=false;
21866 }
21867
21868
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Custom Subscreen Data...");
21869
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsubscreens(f, &tempheader);
21870
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21871
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21872
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21873 113 break;
21874
21875 case ID_FFSCRIPT:
21876
21877 //Freeform combo scripts
21878
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21879 {
21880 box_out("found.");
21881 box_eol();
21882 catchup=false;
21883 }
21884
21885
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading FF Script Data...");
21886
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readffscript(f, &tempheader);
21887
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21888
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21889
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21890 113 break;
21891
21892 case ID_SFX:
21893
21894 //SFX data
21895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21896 {
21897 box_out("found.");
21898 box_eol();
21899 catchup=false;
21900 }
21901
21902
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading SFX Data...");
21903
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readsfx(f, &tempheader);
21904
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21905
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21906
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21907 113 break;
21908
21909 case ID_MIDIS:
21910
21911 //midis
21912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21913 {
21914 box_out("found.");
21915 box_eol();
21916 catchup=false;
21917 }
21918
21919
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Tunes...");
21920
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readtunes(f, &tempheader, tunes);
21921
1/9
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21922
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21923
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21924 125 break;
21925
21926 case ID_CHEATS:
21927
21928 //cheat codes
21929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 if(catchup)
21930 {
21931 box_out("found.");
21932 box_eol();
21933 catchup=false;
21934 }
21935
21936
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("Reading Cheat Codes...");
21937
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 ret=readcheatcodes(f, &tempheader);
21938
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 125 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
125 checkstatus(ret);
21939
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_out("okay.");
21940
1/2
✓ Branch 0 taken 125 times.
✗ Branch 1 not taken.
125 box_eol();
21941 125 break;
21942
21943 case ID_ITEMDROPSETS:
21944
21945 //item drop sets
21946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21947 {
21948 box_out("found.");
21949 box_eol();
21950 catchup=false;
21951 }
21952
21953
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Item Drop Sets...");
21954
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21955
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 113 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21956
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21957
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21958 113 break;
21959
21960 case ID_FAVORITES:
21961
21962 //favorite combos and combo aliases
21963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113 times.
113 if(catchup)
21964 {
21965 box_out("found.");
21966 box_eol();
21967 catchup=false;
21968 }
21969
21970
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("Reading Favorite Combos...");
21971
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21972
1/9
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
113 checkstatus(ret);
21973
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_out("okay.");
21974
1/2
✓ Branch 0 taken 113 times.
✗ Branch 1 not taken.
113 box_eol();
21975 113 break;
21976
21977 default:
21978 if(!catchup)
21979 {
21980 box_out("Bad token! Searching...");
21981 box_eol();
21982 }
21983
21984 catchup=true;
21985 break;
21986 }
21987
21988
21989
1/2
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
2892 if(catchup)
21990 {
21991 //section id
21992 section_id=(section_id<<8);
21993
21994 if(!p_getc(&tempbyte,f))
21995 {
21996 return qe_invalid;
21997 }
21998
21999 section_id+=tempbyte;
22000 }
22001
22002 else
22003 {
22004 //section id
22005
3/4
✓ Branch 0 taken 2892 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✓ Branch 3 taken 125 times.
2892 if(!pack_feof(f))
22006 {
22007
2/4
✓ Branch 0 taken 2767 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2767 times.
✗ Branch 3 not taken.
2767 if(!p_mgetl(&section_id,f))
22008 {
22009 return qe_invalid;
22010 }
22011 2767 }
22012 }
22013 }
22014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 125 times.
125 }
22015 else
22016 {
22017
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
22018
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
22019
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
22020
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
22021
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
22022
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
22023
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
22024
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
22025
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
22026
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
22027
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
22028
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
22029
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
22030
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
22031
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
22032
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
22033
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
22034
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
8 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
22035 };
22036
22037
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 68 times.
140 for (auto& [desc, section_id, fn] : hardcoded_sections)
22038 {
22039 // Would be nice, but old sections mostly did not save section sizes. We could advance by
22040 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
22041 // read all the sections even if requested to skip some.
22042 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
22043 // {
22044 // if (retval == qe_cancel)
22045 // continue;
22046 // checkstatus(retval);
22047 // }
22048
22049
3/6
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 68 times.
✗ Branch 5 not taken.
136 box_out(fmt::format("Reading {}...", desc).c_str());
22050
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 ret = fn();
22051
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 68 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
68 checkstatus(ret);
22052
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_out("okay.");
22053
1/2
✓ Branch 0 taken 68 times.
✗ Branch 1 not taken.
68 box_eol();
22054 }
22055
22056
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✗ Branch 3 not taken.
4 if(!get_bit(skip_flags, skip_subscreens))
22057 {
22058
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 setupsubscreens();
22059
22060
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 4 times.
2052 for(int32_t i=0; i<MAXDMAPS; ++i)
22061 {
22062 2048 int32_t type=DMaps[i].type&dmfTYPE;
22063
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 2036 times.
2048 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
22064
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
22065 2048 }
22066 4 }
22067
22068
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("Setting Up Default Sound Effects...");
22069
22070
2/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
4 if(!get_bit(skip_flags, skip_sfx))
22071 4 setupsfx();
22072
22073
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_out("okay.");
22074
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 box_eol();
22075
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
4 }
22076
22077 129 init_spritelists();
22078
22079 // check data
22080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(f)
22081 {
22082 129 pack_fclose(f);
22083 129 }
22084 129 clear_quest_tmpfile();
22085
22086
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!oldquest)
22087 {
22088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(exists(tmpfilename))
22089 {
22090 delete_file(tmpfilename);
22091 }
22092 129 }
22093
22094
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
129 if(fixffcs && combosread && mapsread)
22095 {
22096 for(int32_t i=0; i<map_count; i++)
22097 {
22098 for(int32_t j=0; j<MAPSCRS; j++)
22099 {
22100 for(int32_t m=0; m<32; m++)
22101 {
22102 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].getData()].type == cCHANGE)
22103 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffCHANGER;
22104 }
22105 }
22106 }
22107 }
22108
22109
2/2
✓ Branch 0 taken 100 times.
✓ Branch 1 taken 29 times.
129 if(get_qr(qr_CONTFULL_DEP))
22110 {
22111 29 set_qr(qr_CONTFULL_DEP, 0);
22112 29 set_bit(zinit.misc, idM_CONTPERCENT, 1);
22113 29 zinit.cont_heart=100;
22114 29 zinit.start_heart=zinit.hc;
22115 29 }
22116
22117 129 box_out("Done.");
22118 129 box_eol();
22119 129 box_end(false);
22120
22121
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_header))
22122 {
22123 129 memcpy(Header, &tempheader, sizeof(tempheader));
22124 129 }
22125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 129 times.
129 if(!get_bit(skip_flags, skip_zinfo))
22126 {
22127 129 ZI.copyFrom(tempzi);
22128 129 }
22129
22130
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_maps))
22131 {
22132 map_count=old_map_count;
22133 }
22134
22135
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_rules))
22136 {
22137 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22138 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22139 }
22140
22141
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if(get_bit(skip_flags, skip_midis))
22142 {
22143 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22144 }
22145
22146 //Debug FFCore.quest_format[]
22147 129 al_trace("Quest made in ZC Version: %x\n", FFCore.quest_format[vZelda]);
22148 129 al_trace("Quest made in ZC Build: %d\n", FFCore.quest_format[vBuild]);
22149 129 al_trace("Quest Section 'Header' is Version: %d\n", FFCore.quest_format[vHeader]);
22150 129 al_trace("Quest Section 'Rules' is Version: %d\n", FFCore.quest_format[vRules]);
22151 129 al_trace("Quest Section 'Strings' is Version: %d\n", FFCore.quest_format[vStrings]);
22152 129 al_trace("Quest Section 'Misc' is Version: %d\n", FFCore.quest_format[vMisc]);
22153 129 al_trace("Quest Section 'Tiles' is Version: %d\n", FFCore.quest_format[vTiles]);
22154 129 al_trace("Quest Section 'Combos' is Version: %d\n", FFCore.quest_format[vCombos]);
22155 129 al_trace("Quest Section 'CSets' is Version: %d\n", FFCore.quest_format[vCSets]);
22156 129 al_trace("Quest Section 'Maps' is Version: %d\n", FFCore.quest_format[vMaps]);
22157 129 al_trace("Quest Section 'DMaps' is Version: %d\n", FFCore.quest_format[vDMaps]);
22158 129 al_trace("Quest Section 'Doors' is Version: %d\n", FFCore.quest_format[vDoors]);
22159 129 al_trace("Quest Section 'Items' is Version: %d\n", FFCore.quest_format[vItems]);
22160 129 al_trace("Quest Section 'Weapons' is Version: %d\n", FFCore.quest_format[vWeaponSprites]);
22161 129 al_trace("Quest Section 'Colors' is Version: %d\n", FFCore.quest_format[vColours]);
22162 129 al_trace("Quest Section 'Icons' is Version: %d\n", FFCore.quest_format[vIcons]);
22163 //al_trace("Quest Section 'Gfx Pack' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vGfxPack]);
22164 129 al_trace("Quest Section 'InitData' is Version: %d\n", FFCore.quest_format[vInitData]);
22165 129 al_trace("Quest Section 'Guys' is Version: %d\n", FFCore.quest_format[vGuys]);
22166 129 al_trace("Quest Section 'MIDIs' is Version: %d\n", FFCore.quest_format[vMIDIs]);
22167 129 al_trace("Quest Section 'Cheats' is Version: %d\n", FFCore.quest_format[vCheats]);
22168 //al_trace("Quest Section 'Save Format' is Version: %d; qst.cpp doesn't read this!\n", FFCore.quest_format[vSaveformat]);
22169 129 al_trace("Quest Section 'Combo Aliases' is Version: %d\n", FFCore.quest_format[vComboAliases]);
22170 129 al_trace("Quest Section 'Player Sprites' is Version: %d\n", FFCore.quest_format[vHeroSprites]);
22171 129 al_trace("Quest Section 'Subscreen' is Version: %d\n", FFCore.quest_format[vSubscreen]);
22172 129 al_trace("Quest Section 'Dropsets' is Version: %d\n", FFCore.quest_format[vItemDropsets]);
22173 129 al_trace("Quest Section 'FFScript' is Version: %d\n", FFCore.quest_format[vFFScript]);
22174 129 al_trace("Quest Section 'SFX' is Version: %d\n", FFCore.quest_format[vSFX]);
22175 129 al_trace("Quest Section 'Favorites' is Version: %d\n", FFCore.quest_format[vFavourites]);
22176 129 al_trace("Quest Section 'CompatRules' is Version: %d\n", FFCore.quest_format[vCompatRule]);
22177 //Print metadata for versions under 2.10 here. Bleah.
22178
2/2
✓ Branch 0 taken 125 times.
✓ Branch 1 taken 4 times.
129 if( FFCore.quest_format[vZelda] < 0x210 )
22179 {
22180 4 zprint2("\n[ZQUEST CREATOR METADATA]\n");
22181
22182
1/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
4 switch(FFCore.quest_format[vZelda])
22183 {
22184 case 0x193:
22185 {
22186 zprint2("Last saved in ZC Editor Version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22187 }
22188 case 0x192:
22189 {
22190 zprint2("Last saved in ZC Editor Version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22191 }
22192 case 0x190:
22193 {
22194 4 zprint2("Last saved in ZC Editor Version: 1.90");
22195
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22196 4 else zprint2("\n");
22197 4 break;
22198 }
22199 case 0x188:
22200 {
22201 zprint2("Last saved in ZC Editor Version: 1.88");
22202 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22203 else zprint2("\n");
22204 break;
22205 }
22206 case 0x187:
22207 {
22208 zprint2("Last saved in ZC Editor Version: 1.87");
22209 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22210 else zprint2("\n");
22211 break;
22212 }
22213 case 0x186:
22214 {
22215 zprint2("Last saved in ZC Editor Version: 1.86");
22216 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22217 else zprint2("\n");
22218 break;
22219 }
22220 case 0x185:
22221 {
22222 zprint2("Last saved in ZC Editor Version: 1.85");
22223 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22224 else zprint2("\n");
22225 break;
22226 }
22227 case 0x184:
22228 {
22229 zprint2("Last saved in ZC Editor Version: 1.84");
22230 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22231 else zprint2("\n");
22232 break;
22233 }
22234 case 0x183:
22235 {
22236 zprint2("Last saved in ZC Editor Version: 1.83");
22237 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22238 else zprint2("\n");
22239 break;
22240 }
22241 case 0x182:
22242 {
22243 zprint2("Last saved in ZC Editor Version: 1.82");
22244 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22245 else zprint2("\n");
22246 break;
22247 }
22248 case 0x181:
22249 {
22250 zprint2("Last saved in ZC Editor Version: 1.81");
22251 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22252 else zprint2("\n");
22253 break;
22254 }
22255 case 0x180:
22256 {
22257 zprint2("Last saved in ZC Editor Version: 1.80");
22258 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22259 else zprint2("\n");
22260 break;
22261 }
22262 default:
22263 {
22264 zprint2("Last saved in ZC Editor Version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22265 }
22266 }
22267 4 }
22268
22269 129 return qe_OK;
22270
22271 invalid:
22272 box_out("error.");
22273 box_eol();
22274 box_end(true);
22275
22276 if(f)
22277 {
22278 pack_fclose(f);
22279 }
22280
22281 if(!oldquest)
22282 {
22283 if(exists(tmpfilename))
22284 {
22285 delete_file(tmpfilename);
22286 }
22287 }
22288
22289 return qe_invalid;
22290
22291 129 }
22292
22293 129 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata, bool report, byte qst_num)
22294 {
22295 129 const char* basename = get_filename(filename);
22296 129 zapp_reporting_add_breadcrumb("load_quest", basename);
22297 129 zapp_reporting_set_tag("qst.filename", basename);
22298
22299 129 loading_qst_name = filename;
22300 129 loading_qst_num = qst_num;
22301 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22302 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22303
1/2
✓ Branch 0 taken 129 times.
✗ Branch 1 not taken.
129 if (!is_ci())
22304 loadquest_report = report;
22305 129 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22306 129 load_tmp_zi = NULL;
22307 129 loading_qst_name = NULL;
22308 129 loadquest_report = false;
22309 129 loading_qst_num = 0;
22310
22311 129 zapp_reporting_set_tag("qst.title", Header->title);
22312 129 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22313
22314 129 return ret;
22315 }
22316